import types
import pygame
from StringIO import StringIO
+from events import NOTEON
class _EventDispatcher :
def __init__(self) :
events = pygame.event.get()
for event in events :
listeners = self.registry.get(event.type, [])
+ if event.type == NOTEON :
+ print len(listeners)
for listener in listeners :
listener(event)
+ def reset(self) :
+ self.registry = {}
def __repr__(self) :
out = StringIO()
EventDispatcher.addEventListener(v.__eventtype__, listener)
def ctor(self, *args, **kw) :
- init_listeners(self)
default_ctor = dict.get('__init__')
if not default_ctor :
super(cls, self).__init__(*args, **kw)
else :
default_ctor(self, *args, **kw)
+ init_listeners(self)
cls.__init__ = ctor