Reputation: 131
I have a class which inherits from GObject. I need to emit a signal and stop when I receive a non-None result from any callback.
Something like this..
class A(GObject.Object):
__gsignals__ = {'get_my_object':(GObject.SIGNAL_RUN_LAST, subClassGObject, (int,))}
def get_the_object(self):
my_obj = self.emit('get_my_object')
Among the callbacks which ever returns the first non-None result that should be stored in my_obj, I don't know if this has to do with some kind of an 'accumulator' function. How do I get this done in pygtk?
Upvotes: 1
Views: 163
Reputation: 57880
If you use the @GObject.Signal
decorator, you can pass it an accumulator
parameter. Documentation is here: https://github.com/GNOME/pygobject/blob/b2529624b3925adbef2671025e08cbf747f162e8/gi/_signalhelper.py#L49
@GObject.Signal(accumulator=GObject.signal_accumulator_first_wins)
def my_signal(self):
return None
Upvotes: 1