View Single Post
  #4  
Old 04-15-2010, 01:45 PM
IGoudt IGoudt is offline
Member
 
Join Date: Sep 2009
Posts: 20
Exactly *what* does not work? On which line does the program do other than you expect it to do?
Following changes might not work, but at least it should call test_reaction_time() correctly. Issue is that end_green_face_task() will run at the same time (I think). You can move that method call to test_reaction_time() as well, but why do you need a viztask for a key event? You can also register the P button with the function end_green_face_task()
Code:
class Experiment:

        # This method is called somewhere...
	def start_green_face_task(self):
		self.avatar_to_morph().make_green_face()
		viztask.schedule(self.test_reaction_time()) # Here the code should stop until this method returns (when the user presses P)! But how can this be achieved?
		self.end_green_face_task() # This method should be called *after* the user presses P!
		
	def test_reaction_time(self):
		yield viztask.waitKeyDown('P')
		
		
	def end_green_face_task(self):
		self.avatar_to_morph().remove_green_face()
Reply With Quote