The event module implements the classes that make up the event system.
The Event class and its subclasses are used to represent “stuff that happens”.
The EventEmitter class provides an interface to connect to events and
to emit events. The EmitterGroup groups EventEmitter objects.

Class describing events that occur and can be reacted to with callbacks.
Each event instance contains information about a single event that has
occurred such as a key press, mouse motion, timer activation, etc.

Subclasses: KeyEvent, MouseEvent, TouchEvent,
StylusEvent

The creation of events and passing of events to the appropriate callback
functions is the responsibility of EventEmitter instances.

Note that each event object has an attribute for each of the input
arguments listed below.

This boolean property indicates whether the event will be delivered
to event callbacks. If it is set to True, then no further callbacks
will receive the event. When possible, it is recommended to use
Event.handled rather than Event.blocked.

This boolean property indicates whether the event has already been
acted on by an event handler. Since many handlers may have access to
the same events, it is recommended that each check whether the event
has already been handled as well as set handled=True if it decides to
act on the event.

Each instance of EventEmitter represents the source of a stream of similar
events, such as mouse click events or timer activation events. For
example, the following diagram shows the propagation of a mouse click
event to the list of callbacks that are registered to listen for that
event:

Emit a new event object, created with the given keyword
arguments, which must match with the input arguments of the
corresponding event class. Note that the ‘type’ argument is
filled in by the emitter.

Alternatively, the emitter can also be called with an Event
instance as the only argument. In this case, the specified
Event will be used rather than generating a new one. This allows
customized Event instances to be emitted and also allows EventEmitters
to be chained by connecting one directly to another.

Note that the same Event instance is sent to all callbacks.
This allows some level of communication between the callbacks
(notably, via Event.handled) but also requires that callbacks
be careful not to inadvertently modify the Event.

callback may be either a callable object or a tuple
(object, attr_name) where object.attr_name will point to a
callable object. Note that only a weak reference to object
will be kept.

ref : bool | str

Reference used to identify the callback in before/after.
If True, the callback ref will automatically determined (see
Notes). If False, the callback cannot be referred to by a string.
If str, the given string will be used. Note that if ref
is not unique in callback_refs, an error will be thrown.

position : str

If 'first', the first eligible position is used (that
meets the before and after criteria), 'last' will use
the last position.

before : str | callback | list of str or callback | None

List of callbacks that the current callback should precede.
Can be None if no before-criteria should be used.

after : str | callback | list of str or callback | None

List of callbacks that the current callback should follow.
Can be None if no after-criteria should be used.

Notes

If ref=True, the callback reference will be determined from:

If callback is tuple, the secend element in the tuple.

The __name__ attribute.

The __class__.__name__ attribute.

The current list of callback refs can be obtained using
event.callback_refs. Callbacks can be referred to by either
their string reference (if given), or by the actual callback that
was attached (e.g., (canvas,'swap_buffers')).

If the specified callback is already connected, then the request is
ignored.

If before is None and after is None (default), the new callback will
be added to the beginning of the callback list. Thus the
callback that is connected _last_ will be the _first_ to receive
events from the emitter.

Each key constant is defined as a Key object, which allows comparison with
strings (e.g. ‘A’, ‘Escape’, ‘Shift’). This enables handling of key events
without using the key constants explicitly (e.g. ifev.key=='Left':).

In addition, key objects that represent characters can be matched to
the integer ordinal (e.g. 32 for space, 65 for A). This behavior is mainly
intended as a compatibility measure.