View Single Post
  #6  
Old 03-08-2010, 04:24 AM
IGoudt IGoudt is offline
Member
 
Join Date: Sep 2009
Posts: 20
Whenever you register a function with vizact.onkeydown a reference is made in memory between the keystroke and the function. What you wish to achieve is to break that reference. A way to do that, have your program memorize that reference as a variable and then do some operation on that variable, in this case: removeEvent.

Take for example:
Code:
def initialiseProgram():
     playJokeEvent = vizact.onkeydown(' ', play_first_joke)
     ... other initialisation

def play_first_joke():
     vizact.removeEvent(playJokeEvent)
     .. do your fancy scene stuff here
I have to admit that I am used to program OOP in classes, and the handling of variables is different when using classes in python than when using direct code (self, vs, global). Try this code snippet first, if it doesn't work out well then we might to do some hacking with the [global] statement.

Last edited by IGoudt; 03-08-2010 at 04:29 AM.
Reply With Quote