Closed
Description
Tested in Ubuntu 14.04 with Python 2.7.6 and Debian unstable with Python 3.4.3. with Matplotlib default backend (TkAgg). Matplotlib loaded from distro repositories.
The following code should stop after 1 tick but instead continues printing ticks forever:
#!/usr/bin/env python
import matplotlib.pyplot as P
def fn():
timer.stop()
print("tick")
fig, ax = P.subplots()
timer = fig.canvas.new_timer(interval=1000)
timer.add_callback(fn)
timer.start()
P.show()
Workaround is to replace "timer.stop()" with
timer.single_shot = True
and that does stop the timer upon execution.
Documentation describing stop() method:
http://matplotlib.org/api/backend_bases_api.html#matplotlib.backend_bases.TimerBase