Skip to content

Commit bc7a993

Browse files
committed
Fix stopping of Tk timers from with timer callback.
1 parent a5d9254 commit bc7a993

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ def _on_timer(self):
9494
TimerBase._on_timer(self)
9595

9696
# Tk after() is only a single shot, so we need to add code here to
97-
# reset the timer if we're not operating in single shot mode.
98-
if not self._single and len(self.callbacks) > 0:
97+
# reset the timer if we're not operating in single shot mode. However,
98+
# if _timer is None, this means that _timer_stop has been called; so
99+
# don't recreate the timer in that case.
100+
if not self._single and self._timer:
99101
self._timer = self.parent.after(self._interval, self._on_timer)
100102
else:
101103
self._timer = None

0 commit comments

Comments
 (0)