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:
|
Event containing a message payload. |
|
|
-
class
PayloadEvent
(etype, eid, value)[source] Bases:
PyCommandEvent
Event containing a message payload.
Methods:
GetValue
()Returns the value from the 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