Hi all,
I'm using a timer object to interact with the MPL event loop on my
OS X laptop. However, it seems to be missing a few key methods that
are making using it a little difficult. In particular, I can’t find
a way to stop the timer from sending events:
$ ipython --pylab
In [1]: def fun():
...: for i in range(5): ...: print "We're having fun!"; yield ...: for i in range(5): ...: print "Too much fun..."; yield ...: while True: ...: print "Stop the fun! No more!"; yield In [2]: f = fun().next In [3]: fig = plt.figure() In [4]: t = fig.canvas.new_timer() In [5]: t.add_callback(f) In [6]: t.start() In [7]: t.stop() In [8]: del t # It's all over now...
It looks like the stop method may never have been implemented:
In [3]: t.stop??
Type: instancemethod String Form:<bound method TimerMac.stop of Timer object
0x106ba33b0 wrapping CFRunLoopTimerRef 0x0>
File:
/usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.py
Definition: t.stop(self) Source: def stop(self): ''' Stop the timer. ''' self._timer_stop() In [4]: t._timer_stop?? Type: instancemethod String Form:<bound method TimerMac._timer_stop of Timer object
0x106ba33b0 wrapping CFRunLoopTimerRef 0x0>
File:
/usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.py
Definition: t._timer_stop(self) Source: def _timer_stop(self): pass
I'm able to remove the callback function from the timer's callback
list, but I suspect that won’t stop the events from being triggered.
But I’d really prefer to completely stop the timer events, since in
my application I may end up going through many timers.
Is this the expected behavior? Is there an easy fix I'm overlooking?
Version info:
In [3]: sys.version
Out[3]: '2.7.3 (default, Feb 19 2013, 18:00:31) \n[GCC 4.2.1
Compatible Apple LLVM 4.2 (clang-425.0.24)]’
In [4]: mpl.__version__ Out[4]: '1.2.0'
Thanks,
Justin