Thread: Push a button
View Single Post
  #2  
Old 07-20-2009, 09:39 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use the vizact library to enable a timer while the button is down. Here is a simple script showing how to do this:
Code:
import viz
import vizact
viz.go()

# Create model
model = viz.add('logo.ive',pos=(0,1,5))

# Create function to rotate model
def RotateModel():
	model.setEuler(90*viz.elapsed(),0,0,viz.REL_LOCAL)
	
# Create disabled timer to call RotateModel function
rotateTimer = vizact.ontimer(0,RotateModel)
rotateTimer.setEnabled(False)

# Create button
rotateButton = viz.addButton(pos=(0.9,0.1,0))

# Enable rotate timer while button is pressed
vizact.onbuttondown(rotateButton,rotateTimer.setEnabled,True)
vizact.onbuttonup(rotateButton,rotateTimer.setEnabled,False)
Reply With Quote