Penguin
05-12-2009, 11:48 AM
Hi, is it possible to register more than one function for listing on a custom event? When pressing the 'e'-button the following code should print out 'B' and 'C'. But only 'C' is printed out. When I swap the two *.enableEvent(EVENT) lines then 'B' is printed out.
Therefore I guess only one function can listen to an event at the same time. Am I right?
import viz
class A(object):
def __init__(self):
pass
def enableEvent(self, EventID):
viz.callback(EventID,self.doit)
def doit(self):
pass
class B(A):
def __init__(self):
pass
def doit(self):
print "B"
class C(A):
def __init__(self):
pass
def doit(self):
print "C"
viz.go()
EVENT = viz.getEventID('EVENT')
b = B()
b.enableEvent(EVENT)
c = C()
c.enableEvent(EVENT)
def sendEvent():
viz.sendEvent(EVENT)
vizact.onkeydown('e',sendEvent)
Therefore I guess only one function can listen to an event at the same time. Am I right?
import viz
class A(object):
def __init__(self):
pass
def enableEvent(self, EventID):
viz.callback(EventID,self.doit)
def doit(self):
pass
class B(A):
def __init__(self):
pass
def doit(self):
print "B"
class C(A):
def __init__(self):
pass
def doit(self):
print "C"
viz.go()
EVENT = viz.getEventID('EVENT')
b = B()
b.enableEvent(EVENT)
c = C()
c.enableEvent(EVENT)
def sendEvent():
viz.sendEvent(EVENT)
vizact.onkeydown('e',sendEvent)