![]()  | 
	
| 
	 | 
| 
		 
			 
			#1  
			
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 
				
				want to add a stop watch to my application!
			 
			
			
			i want to add a stop watch to my application so that when ever i press a key from the keyboard it should start the watch and when i press another key it should stop.. is there any inbuild function in vizard for a watch?
		 
		
		
		
		
		
		
		
		
	
	 | 
| 
		 
			 
			#2  
			
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
		
		 
			
			You can use the vizact.ontimer function to update the stop watch time. I created a simple wrapper class around this for starting/stopping the watch. Here is the sample script: 
		
		
		
		
		
		
		
		
	
	Code: 
	import viz
viz.go()
class StopWatch(object):
	def __init__(self):
		self.time = 0.0
		
		self._timer = vizact.ontimer(0,self._updateTime)
		self._timer.setEnabled(False)
		
	def _updateTime(self):
		self.time += viz.elapsed()
		
	def start(self):
		self._timer.setEnabled(True)
		
	def stop(self):
		self._timer.setEnabled(False)
		
	def toggle(self):
		self._timer.setEnabled(viz.TOGGLE)
		
#Create stop watch object
watch = StopWatch()
#Spacebar toggles stop watch
vizact.onkeydown(' ',watch.toggle)
#Create text object to display watch time
text = viz.addText('',parent=viz.ORTHO,fontSize=40)
#Setup timer to update text object with watch time every frame
def DisplayTime():
	text.message('%.2f'%(watch.time))
vizact.ontimer(0,DisplayTime)
 | 
| 
		 
			 
			#3  
			
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 
				
				thanks for your reply...im getting this warning message!
			 
			
			
			farshizzo thanks for your reply...i tried with ur code..but im getting this message... 
		
		
		
		
		
		
		
		
	
	before Font::Glyph::subload(): detected OpenGL error 'invalid enumerant what is the meaning of this message?  | 
![]()  | 
	
	
| Thread Tools | |
| Display Modes | Rate This Thread | 
		
  | 
	
		
  | 
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| How to stop vizact.move | Jerry | Vizard | 3 | 06-04-2009 05:25 PM | 
| Stop moving after few seconds?? | Chrissy2009 | Vizard | 8 | 05-10-2009 03:47 PM | 
| collideNone() failing to stop collision | spdegabrielle | Vizard | 3 | 05-07-2009 02:35 PM | 
| Free Walkthrough Application Code | Gladsomebeast | Vizard | 0 | 03-03-2009 05:02 PM | 
| Calling Matlab application from Wizard | luzanin | Vizard | 1 | 01-31-2007 10:48 AM |