class documentation

class Event(list):

Constructor: Event(name, runInBackground)

View In Hierarchy

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 runInBackground Indicator whether an event should be handled in a separate thread.
@overload
def __call__(self, func: _F) -> _F:
@overload
def __call__(self, *args: 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:AnyUnnamed function arguments.
**kwargs:AnyKeyword function arguments.
def __init__(self, name: str | None = None, runInBackground: bool | None = True):

Event initialization.

Parameters
name:str | NoneThe event name.
runInBackground:bool | NoneIndicator whether an event should be handled in a separate thread.
def __repr__(self) -> str:

Event reprsentation.

Returns
strString representation of the event.
__slots__: tuple[str, ...] =

Slots of the Event class.

name =

The event name.

runInBackground =

Indicator whether an event should be handled in a separate thread.