Event dispatcher(see python-whistle.github.io).
whistle的Python项目详细描述
whistle是一个轻量级的python库,它允许应用程序组件通过 分派事件并倾听它们。
安装
pip install whistle
快速启动
安装哨子包:
$ pip install whistle
创建事件分派器:
fromwhistleimportEventDispatcherdispatcher=EventDispatcher()
添加侦听器以对事件作出反应
defon_spectacle_starts(event):print('Please turn down your phones!')dispatcher.add_listener('spectacle.starts',on_spectacle_starts)</code></pre>
派遣!
dispatcher.dispatch('spectacle.starts')
由Romain Dorgueil和contributors制成。