一个通用的mixin,用于对任何python类进行add on()、off()和trigger()样式的事件处理。
onoff的Python项目详细描述
OnFox是一个Python模块,它提供了可以使用的
示例
>>>fromonoffimportOnOffMixin>>>classFoo(OnOffMixin):...def__init__(self):...self.on("hello",self.hello)...defhello(self,*args):...print("Hello: %s"%args)...deftest(self,*args):...self.trigger("hello",*args)...>>>f=Foo()>>>f.test("Triggered events rock!")Hello:Triggeredeventsrock!