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.

24 lines
504 B

  1. import wx
  2. from collections import defaultdict
  3. __ALL__ = ['pub']
  4. class PubSub(object):
  5. '''
  6. A super simplified clone of Wx.lib.pubsub since it doesn't exist on linux
  7. '''
  8. def __init__(self):
  9. self.registry = defaultdict(list)
  10. def subscribe(self, event, handler):
  11. self.registry[event].append(handler)
  12. def send_message(self, event, **kwargs):
  13. for event_handler in self.registry.get(event, []):
  14. wx.CallAfter(event_handler, **kwargs)
  15. pub = PubSub()