Signal Functions
The urwid.*_signal() functions use a shared Signals object instance
for tracking registered and connected signals. There is no reason to
instantiate your own Signals object.
-
urwid.connect_signal(obj, name, callback, user_arg=None)
-
Signals.connect(obj, name, callback, user_arg=None)
Parameters: |
- obj (object) – the object sending a signal
- name (signal name) – the signal to listen for, typically a string
- callback (function) – the function to call when that signal is sent
- user_arg – optional additional argument to callback, if None
no arguments will be added
|
When a matching signal is sent, callback will be called with
all the positional parameters sent with the signal. If user_arg
is not None it will be sent added to the end of the positional
parameters sent to callback.
-
urwid.disconnect_signal(obj, name, callback, user_arg=None)
-
Signals.disconnect(obj, name, callback, user_arg=None)
This function will remove a callback from the list connected
to a signal with connect_signal().
-
urwid.register_signal(sig_cls, signals)
-
Signals.register(sig_cls, signals)
Parameters: |
- sig_class (class) – the class of an object that will be sending signals
- signals (signal names) – a list of signals that may be sent, typically each
signal is represented by a string
|
This function must be called for a class before connecting any
signal callbacks or emiting any signals from that class’ objects
-
urwid.emit_signal(obj, name, *args)
-
Signals.emit(obj, name, *args)
Parameters: |
- obj (object) – the object sending a signal
- name (signal name) – the signal to send, typically a string
- *args – zero or more positional arguments to pass to the signal
callback functions
|
This function calls each of the callbacks connected to this signal
with the args arguments as positional parameters.
This function returns True if any of the callbacks returned True.