Event subscription.
A list of callable methods. Calling an instance of Event will cause a call to each function in the list in ascending order by index. It supports all methods from its base class (list), so use append() and remove() to add and remove functions.
An event is raised by calling the event: anEvent(anArgument). It may have an arbitrary number of arguments which are passed to the functions.
The function will be called in a separate thread in order to prevent waiting for the returns. This might lead to some race conditions, so the synchronizations must be done inside the functions.
Attention
Since the parent class is a list calling isInstance(obj, list) will return True.
| Method | __call__ |
Handle calling an event instance. This call is forwarded to all of the registered callback functions for this event. |
| Method | __init__ |
Event initialization. |
| Method | __repr__ |
Event reprsentation. |
| Class Variable | __slots__ |
Slots of the Event class. |
| Instance Variable | name |
The event name. |
| Instance Variable | run |
Indicator whether an event should be handled in a separate thread. |
Any, **kwargs: Any):Handle calling an event instance. This call is forwarded to all of the registered callback functions for this event.
If the event was created with runInBackground as True,
then the callbacks are called sequentially (not individually!) as a thread.
This method is used in two ways: 1) as a decorator to register an event handler,
and 2) to raise an event by calling the event instance. The method distinguishes between
the two cases by checking whether the first argument is a callable function and whether
it is an instance of EventData (in which case it
| Parameters | |
*args:Any | Unnamed function arguments. |
**kwargs:Any | Keyword function arguments. |