-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
input() caused _tkinter.TclError: invalid command name XXX after plot.close() #17104
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
Comments
Looks like we need something like diff --git i/lib/matplotlib/backends/_backend_tk.py w/lib/matplotlib/backends/_backend_tk.py
index 600722dfc..6df556c7f 100644
--- i/lib/matplotlib/backends/_backend_tk.py
+++ w/lib/matplotlib/backends/_backend_tk.py
@@ -218,8 +218,11 @@ class FigureCanvasTk(FigureCanvasBase):
# to the window and filter.
def filter_destroy(event):
if event.widget is self._tkcanvas:
+ self._destroying = True
self._master.update_idletasks()
self.close_event()
+
+ self._destroying = False
root.bind("<Destroy>", filter_destroy, "+")
self._master = master
@@ -253,7 +256,8 @@ class FigureCanvasTk(FigureCanvasBase):
def idle_draw(*args):
try:
- self.draw()
+ if not self._destroying:
+ self.draw()
finally:
self._idle = True (Basically, Brownie points to whoever takes this patch, checks that it works, and turns it into a proper PR. |
matplotlib#17104 Tested on - OS: Windows 10 - Matplotlib backend: TkAgg - Python: 3.7.7
@anntzer I have built matplotlib and tested the patch you provided works on my machine. When creating a pull request, however, I was confused by the following two lines within the pull-request template:
Thanks. |
Hi @davidhcefx. First, thanks for the interest in contributing! To answer your questions
|
@davidhcefx Did you open a PR? While we do try to get tests on everything, I do not think we should hold merging this on reproducing the race condition that leads to this on CI. |
Idle callbacks will trigger exceptions after canvas been destroyed. Bug matplotlib#17104
@tacaswell I have just opened a PR. Sorry for the delay. |
This is fixed on master and v3.2.x, by #17391, I believe, while fixing a different issue. |
Is anyone else still having this issue? I have matplotlib version |
@mercerb Can you open a new issue with system + version details? We have in the past seen behavior that depends on both the OS and tk versions... |
Yep makes sense, but I actually just realized what the issue was. I had a |
Bug report
Bug summary
By calling the built-in
input()
function after closing the plot within an animation object, I got a Tkinter exception.Code for reproduction
Actual outcome
Expected outcome
No exception regarding Tkinter been thrown.
Matplotlib version
print(matplotlib.get_backend())
): TkAggI installed matplotlib via
python -m pip install matplotlib
.The text was updated successfully, but these errors were encountered: