[pygtk] How do I accumulate return values from a signal

Walter Leibbrandt walter at translate.org.za
Tue Sep 29 21:17:12 WST 2009


Op 29/09/2009 14:25, samwyse het geskryf:
> When my main program emits a signal, is there a best way to accumulate
> the results returned by everything that is connected?  The
> documentation refers to a gobject method that hints at doing this:
> "The signal_accumulator_true_handled() function is only used as
> accumulator argument when registering signals."  However, I see no
> other references to "accumulator arguments" anywhere.  I've also
> thought of passing, say, a list object as an extra parameter and
> letting each plug-in append to the list before returning.
>
> Finally, I intend to use the above to allow a plug-in to insert itself
> into the GUI.  Maybe I'm taking the wrong approach.  Is there a better
> way to allow a plug-in to insert action groups or add ui from a
> string?

I tend to use a slightly different approach... Since the first argument 
to a signal is always the emitting object, you have the opportunity to 
use it in any signal handler. So, in your case, you can simply use an 
attribute of the object that the handlers modify.

HTH
-- 
Walter Leibbrandt                  Software Developer
Recent blogs:
* Showing the current git branch in the Bash prompt
http://www.translate.org.za/blogs/walter/en/content/showing-current-git-branch-bash-prompt



More information about the pygtk mailing list