|
#1
|
|||
|
|||
vhil module
so i want to make a "vhil" module that works in much the same way as the "viz" module. that is, make generic calls like vhil.add, vhil.get, vhil.callback, etc., but it does some added functionality not built into vizard, but necessary for our projects.
Basically, people at our lab are reinventing the wheel a lot, and i want to make a generic library that makes common calls to the viz library. so my questions so far are: 1) if I call viz.callback(viz.TIMER_EVENT, ...) or for any callback type, will my module overwrite any callbacks set by the user? or will it just add another callback? 2) if the user starts a timer with the same number as one of my timers, and both their script and my module have timer-event callbacks, will we both get eachother's timer events, or do the two viz.callback(...) calls set up independent timer/callback systems. i hope this makes sense, as the rest of my questions depend on the answers for these two. thanks adrian |
#2
|
|||
|
|||
Hi,
1) Yes, your callback will overwrite any callback set by the user 2) Well, if you register a timer callback then it will overwrite the users timer callback, so they won't get any timer events. Using an Event Class is the proper way to handle events in separate modules. For example, if you wanted your module to handle timer and keydown events you would do the following: Code:
import viz #Create class that inherits from viz.EventClass class _VHILEvent(viz.EventClass): def __init__(self): viz.EventClass.__init__(self) #Register callback for this class instance self.callback(viz.TIMER_EVENT,self.mytimer) self.callback(viz.KEYDOWN_EVENT,self.mykeydown) #Start a timer that belongs to this instance self.starttimer(0,0.1,viz.FOREVER) def mytimer(self,num): pass def mykeydown(self,key): pass #Create an instance of _VHILEvent class _VE = _VHILEvent() |
#3
|
|||
|
|||
eeexxcellent....
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|