You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
548 B

from collections import defaultdict
__ALL__ = ['pub']
class PubSub(object):
'''
A super simplified clone of Wx.lib.pubsub since it doesn't exist on linux
*grumble grumble* Stupid abandoned wx project... >:( *grumble*
'''
def __init__(self):
self.registry = defaultdict(list)
def subscribe(self, handler, event):
self.registry[event].append(handler)
def send_message(self, event, **kwargs):
for event_handler in self.registry.get(event, []):
event_handler(**kwargs)
pub = PubSub()