Skip to content

Commit cef4c0d

Browse files
use after idle after 0 incantation for TkTimer
1 parent 035bf30 commit cef4c0d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,16 @@ def _on_timer(self):
9696
# if _timer is None, this means that _timer_stop has been called; so
9797
# don't recreate the timer in that case.
9898
if not self._single and self._timer:
99-
self._timer = self.parent.after(self._interval, self._on_timer)
99+
if self._interval:
100+
self._timer = self.parent.after(self._interval, self._on_timer)
101+
else:
102+
# Edge case: Tcl after 0 semantics *prepend* events to the queue
103+
# so a 0 interval does not allow any other events to run.
104+
# This incantation is cancellable and runs as fast as possible
105+
# while also allowing events and drawing every frame. GH#18236
106+
self._timer = self.parent.after_idle(
107+
lambda: self.parent.after(self._interval, self._on_timer)
108+
)
100109
else:
101110
self._timer = None
102111

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy