View Single Post
  #2  
Old 10-24-2011, 06:20 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,466
Try using a task function to control the program flow. In the following code the screen will turn white for 0.5 seconds after the 's' key is pressed:
Code:
import viz
import viztask

viz.go()

def whiteScreen():
	print('White')
	viz.clearcolor(256, 256, 256)

vizact.onkeydown('w', whiteScreen)

def blackScreen():
	print('Black')
	viz.clearcolor(0, 0, 0)

vizact.onkeydown('b', blackScreen)

def signalTask():
	while True:
		yield viztask.waitKeyDown('s')
		whiteScreen()
		yield viztask.waitTime(0.5)
		blackScreen()

viztask.schedule(signalTask())
Reply With Quote