Package pyjamas :: Module Timer
[hide private]
[frames] | no frames]

Source Code for Module pyjamas.Timer

 1  # This is the gtk-dependent Timer module. 
 2  # For the pyjamas/javascript version, see platform/TimerPyJS.py 
 3   
 4  import sys 
 5  from __pyjamas__ import JS 
 6   
 7  global timeout_add 
 8  global timeout_end 
 9  timeout_add = None 
10  timeout_end = None 
11   
12  # the following is needed because we are currently not able to override things 
13  # except functions and classes 
14  if sys.platform not in ['mozilla', 'ie6', 'opera', 'oldmoz', 'safari']: 
15      import pyjd 
16   
17  global timers 
18  timers = None 
19   
20   
21 -def set_timer(interval, fn):
22 pass
23 24
25 -def kill_timer(timer):
26 pass
27 28
29 -def init():
30 global timers 31 timers = []
32 33 init() 34 35
36 -class Timer:
37
38 - def __init__(self, time, notify):
39 if hasattr(notify, "onTimer"): 40 self.notify_fn = notify.onTimer 41 else: 42 self.notify_fn = notify 43 self.timer_id = timeout_add(time, self.notify)
44
45 - def clearInterval(self, timer_id):
46 pass
47
48 - def clearTimeout(self, timer_id):
49 pass
50
51 - def createInterval(self, timer, period):
52 pass
53
54 - def createTimeout(self, timer, delay):
55 pass
56 57 # TODO - requires Window.addWindowCloseListener
58 - def hookWindowClosing(self):
59 pass
60
61 - def notify(self, *args):
62 self._notify(*args)
63
64 - def _notify(self, *args):
65 if not self.notify_fn: 66 return False 67 self.notify_fn(self.timer_id) 68 return False
69
70 - def cancel(self):
71 if not timeout_end: 72 print "TODO: cancel timer", self.timer_id 73 self.notify_fn = None # hmmm.... 74 return 75 if self.timer_id is not None: 76 timeout_end(self.timer_id) 77 self.timer_id = None
78
79 - def run(self):
80 pass
81
82 - def schedule(self, delayMillis):
83 pass
84
85 - def scheduleRepeating(self, periodMillis):
86 pass
87 88 # TODO: UncaughtExceptionHandler, fireAndCatch
89 - def fire(self):
90 pass
91
92 - def fireImpl(self):
93 pass
94
95 - def getID(self):
96 return self.timer_id
97