From bc7a9932752b53cc7ef7538beab482fecfc643ed Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 25 Jul 2017 13:15:17 -0700 Subject: [PATCH] Fix stopping of Tk timers from with timer callback. --- lib/matplotlib/backends/backend_tkagg.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backends/backend_tkagg.py b/lib/matplotlib/backends/backend_tkagg.py index d111408f8409..f6190d4f369e 100644 --- a/lib/matplotlib/backends/backend_tkagg.py +++ b/lib/matplotlib/backends/backend_tkagg.py @@ -94,8 +94,10 @@ def _on_timer(self): TimerBase._on_timer(self) # Tk after() is only a single shot, so we need to add code here to - # reset the timer if we're not operating in single shot mode. - if not self._single and len(self.callbacks) > 0: + # reset the timer if we're not operating in single shot mode. However, + # if _timer is None, this means that _timer_stop has been called; so + # don't recreate the timer in that case. + if not self._single and self._timer: self._timer = self.parent.after(self._interval, self._on_timer) else: self._timer = None