Browse Source

pubsub clone for linux

pull/90/merge
chriskiehl 9 years ago
parent
commit
602f22b420
1 changed files with 25 additions and 0 deletions
  1. 25
      gooey/gui/pubsub.py

25
gooey/gui/pubsub.py

@ -0,0 +1,25 @@
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()
Loading…
Cancel
Save