comparison clients/pychan_demo/pychan_test.py @ 165:fbc55c6f57cf

(Convenient) Timers.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 15 Oct 2008 18:04:52 +0000
parents c305c5eda7ed
children 54bfd1015b35
comparison
equal deleted inserted replaced
164:5b04a7d3ded6 165:fbc55c6f57cf
33 33
34 def stop(self): 34 def stop(self):
35 if self.widget: 35 if self.widget:
36 self.widget.hide() 36 self.widget.hide()
37 self.widget = None 37 self.widget = None
38
39 def testTimer():
40 import timer
41 timer.init( pychan.manager.engine.getTimeManager() )
42 def spam():
43 print "SPAM SPAM"
44 return 1
45 repeater = timer.repeatCall(500,spam)
46 def stop_spam():
47 repeater.stop()
48 print "BACON EGGS AND SPAM"
49 timer.delayCall(5000,stop_spam)
50
38 51
39 class DemoApplication(basicapplication.ApplicationBase): 52 class DemoApplication(basicapplication.ApplicationBase):
40 def __init__(self): 53 def __init__(self):
41 super(DemoApplication,self).__init__() 54 super(DemoApplication,self).__init__()
42 55
73 self.slider = self.gui.findChild(name='slider') 86 self.slider = self.gui.findChild(name='slider')
74 self.slider_value = self.gui.findChild(name='slider_value') 87 self.slider_value = self.gui.findChild(name='slider_value')
75 88
76 self.currentExample = None 89 self.currentExample = None
77 self.creditsWidget = None 90 self.creditsWidget = None
91 testTimer()
78 92
79 def selectExample(self): 93 def selectExample(self):
80 if self.demoList.selected_item is None: return 94 if self.demoList.selected_item is None: return
81 print "selected",self.demoList.selected_item 95 print "selected",self.demoList.selected_item
82 if self.currentExample: self.currentExample.stop() 96 if self.currentExample: self.currentExample.stop()