diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2006-06-15 17:34:39 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2006-06-15 17:34:39 +0000 |
| commit | 10c60652633e62cf120102f36b9354c7d330147c (patch) | |
| tree | 0c206e7e552429dcc8ce9966c1c8fa42c0637160 /lib/python/Tools/Event.py | |
| parent | 2e874fa14264bf37f17ae9b9375e26059e7f35ec (diff) | |
| download | enigma2-10c60652633e62cf120102f36b9354c7d330147c.tar.gz enigma2-10c60652633e62cf120102f36b9354c7d330147c.zip | |
add Event
Diffstat (limited to 'lib/python/Tools/Event.py')
| -rw-r--r-- | lib/python/Tools/Event.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/python/Tools/Event.py b/lib/python/Tools/Event.py new file mode 100644 index 00000000..6b96bff4 --- /dev/null +++ b/lib/python/Tools/Event.py @@ -0,0 +1,23 @@ + +class Event: + def __init__(self, start = None, stop = None): + self.list = [ ] + self.start = start + self.stop = stop + + def __call__(self, *args, **kwargs): + for x in self.list: + x(*args, **kwargs) + + def listen(self, fnc): + was_empty = len(self.list) == 0 + self.list.append(fnc) + if was_empty: + if self.start: + self.start() + + def unlisten(self, fnc): + self.list.remove(fnc) + if len(self.list) == 0: + if self.stop: + self.stop() |
