From 602f22b4202e3f557fe53098e0e14ad2859c8fe7 Mon Sep 17 00:00:00 2001 From: chriskiehl Date: Sat, 6 Jun 2015 15:27:02 -0400 Subject: [PATCH] pubsub clone for linux --- gooey/gui/pubsub.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 gooey/gui/pubsub.py diff --git a/gooey/gui/pubsub.py b/gooey/gui/pubsub.py new file mode 100644 index 0000000..15c4a43 --- /dev/null +++ b/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() +