Skip to content

TkTimer interval=0 workaround #18284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,16 @@ def _on_timer(self):
# 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)
if self._interval > 0:
self._timer = self.parent.after(self._interval, self._on_timer)
else:
# Edge case: Tcl after 0 *prepends* events to the queue
# so a 0 interval does not allow any other events to run.
# This incantation is cancellable and runs as fast as possible
# while also allowing events and drawing every frame. GH#18236
self._timer = self.parent.after_idle(
lambda: self.parent.after(self._interval, self._on_timer)
)
else:
self._timer = None

Expand Down