Signal#

class Signal(name='', func=None, flags=1, return_type=None, arg_types=None, doc='', accumulator=None, accu_data=None)#

Object which gives a nice API for creating and binding signals.

param name:

Name of signal or callable closure when used as a decorator.

type name:

str or callable

param callable func:

Callable closure method.

param GObject.SignalFlags flags:

Flags specifying when to run closure.

param type return_type:

Return type of the Signal.

param list arg_types:

List of argument types specifying the signals function signature

param str doc:

Documentation of signal object.

param callable accumulator:

Accumulator method with the signature: func(ihint, return_accu, handler_return, accu_data) -> boolean

param object accu_data:

User data passed to the accumulator.

Example:

class Spam(GObject.Object):
    velocity = 0

    @GObject.Signal
    def pushed(self):
        self.velocity += 1

    @GObject.Signal(flags=GObject.SignalFlags.RUN_LAST)
    def pulled(self):
        self.velocity -= 1

    stomped = GObject.Signal('stomped', arg_types=(int,))

    @GObject.Signal
    def annotated_signal(self, a:int, b:str):
        "Python3 annotation support for parameter types.

def on_pushed(obj):
    print(obj)

spam = Spam()
spam.pushed.connect(on_pushed)
spam.pushed.emit()

Methods#

class Signal
get_signal_args()#

Returns a tuple of: (flags, return_type, arg_types, accumulator, accu_data)