Event

class pynetevents.Event(propagate_exceptions=None, allow_duplicate_listeners=None, use_weakref_slot=None)

Bases: object

Descriptor for event slots in classes.

__get__(instance, owner)

Get the EventSlot for the owner class instance.

Return type:

EventSlot

__init__(propagate_exceptions=None, allow_duplicate_listeners=None, use_weakref_slot=None)

Initialize an EventSlot descriptor.

Parameters:
  • propagate_exceptions (Optional[bool], optional) – If True, exceptions raised by event listeners are propagated to the caller. If False, exceptions are caught and suppressed.

  • allow_duplicate_listeners (Optional[bool], optional) – If True, the same listener function can be added multiple times to the same event. If False, duplicate listeners are throw an exceptions

  • use_weakref_slot (Optional[bool], optional) – If True, event listeners are stored as weak references if possible, allowing classes that the listeners belong to to be garbage collected.

If parameters are omitted the defaults (propagate_exceptions: True, allow_duplicate_listeners: False, use_weakref_slot: False) are used.

__set__(instance, value)

Allows only assignment that comes from in-place operations (+= or -=), more specifically restricts one to assigning only the same EventSlot instance to itself (although it may be changed).

Return type:

None

__set_name__(owner, name)

Automatically set the event name from the attribute name if not given.

property name: str

Get the name of the event.