1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Echo: Callback Properties in Python
===================================
Overview
--------
Echo is a small Python module to create properties that you can attach callback
functions to::
>>> from echo import CallbackProperty, add_callback
>>> class Switch(object):
... state = CallbackProperty('off')
>>> def alert(value):
... print("The switch is %s" % value)
>>> s = Switch()
>>> add_callback(s, 'state', alert)
>>> s.state
'off'
>>> s.state = 'on'
The switch is on
>>> s.state
'on'
>>> s.state = 'off'
The switch is off
The main features of Echo are:
* A simple, property-like interface to monitor state changes
* Decorator syntax to create callback property getter/setter methods, similar to
``@property``
* Context managers to delay or ignore callback events
* Helper functions to connect callback properties to GUI elements (at the moment
only Qt is supported)
User guide
----------
.. toctree::
:maxdepth: 1
installation
core
gui
api
|