__init__(self,
delayMillis=0,
notify=None)
(Constructor)
| source code
|
Called with no arguments, create a timer that will call its run()
method when it is scheduled and fired. This usage requires subclassing
to implement the run() method. This is GWT's interface and
behaviour.
There are two enhancements to pyjamas' implementation when specified
with special keyword arguments, one of which obviates the need for
subclassing:
timer = Timer(delayMillis=ms)
is identical to:
timer = Timer()
timer.schedule(ms)
and:
timer = Timer(notify=object_or_func)
is the same as:
timer = Timer()
run = getattr(object_or_func, 'onTimer', object_or_func)
if not callable(run): raise ValueError, msg
i.e., the value passed to notify is checked to see if it has an
onTimer attribute; if so, it is used as the callable, if not, the object
itself is used as the callable.
NOTE: when notify is specified, the function or method will be called
with one argument: the instance of the timer. So, this would be proper
usage:
def timer_cb(timer):
...
timer = Timer(notify=timer_cb)
or:
class myclass:
def __init__(self):
...
self.timer = Timer(notify=self)
def onTimer(self, timer):
...
- Overrides:
object.__init__
|