events

Reusable code for simple events

Usage:

>>> from domdf_wxpython_tools import events
>>> # Create the event outside of the class
>>> myEVT = events.SimpleEvent()
>>> # Set the receiver to the class you want.
>>> # This is usually done from within the receiver class
>>> class MyClass(object):
...     def __init__(self):
...         myEVT.set_receiver(self)
...
...         # Then bind the event to a handler
...         myEVT.Bind(self.handler)
...
...     def handler(self):
...         '''Handler for myEVT'''
...         pass
>>> # From within the thread, trigger the event with the following syntax:
>>> myEVT.trigger()

Classes:

PayloadEvent(etype, eid, value)

Event containing a message payload.

SimpleEvent([receiver, name])

param receiver

class PayloadEvent(etype, eid, value)[source]

Bases: PyCommandEvent

Event containing a message payload.

Methods:

GetValue()

Returns the value from the event.

GetValue()[source]

Returns the value from the event. @return: the value of this event

class SimpleEvent(receiver=None, name='Event')[source]

Bases: object

Parameters
  • receiver – Default None.

  • name – Default 'Event'.

Methods:

Bind(handler[, receiver])

Bind the event to the handler.

Unbind([receiver])

Unbind the event from the handler

__repr__()

Return a nicely formatted representation string.

set_receiver(receiver)

Set the class that is to receive the event trigger.

trigger([value])

Trigger the event

Bind(handler, receiver=None, **kwargs)[source]

Bind the event to the handler.

Parameters
  • handler – handler to bind the event to.

  • kwargs – keyword arguments to pass through to receiver’s Bind method.

Unbind(receiver=None, **kwargs)[source]

Unbind the event from the handler

Parameters

kwargs – keyword arguments to pass through to receiver’s Unbind method

__repr__()[source]

Return a nicely formatted representation string.

set_receiver(receiver)[source]

Set the class that is to receive the event trigger.

Parameters

receiver

trigger(value=None)[source]

Trigger the event