From 5a18309f6fe85bdb19e7b41b21dfb93e0474d17d Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 26 Jun 2019 10:24:28 +0200 Subject: [PATCH] Remove reference to old Tk/Windows bug. See patch. At least I can't repro it on Windows, and you'd expect it to be semi-regularly reported on the tracker if it still occurred. In the example, don't bother calling `root.destroy()`, as `root.quit()` already handles the destroying (both on Linux and Windows, an additional call to `root.destroy()` results in "can't invoke "destroy" command: application has been destroyed"). --- examples/user_interfaces/embedding_in_tk_sgskip.py | 12 +----------- lib/matplotlib/backends/_backend_tk.py | 4 ---- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/examples/user_interfaces/embedding_in_tk_sgskip.py b/examples/user_interfaces/embedding_in_tk_sgskip.py index 43c1e1523442..2446619d462e 100644 --- a/examples/user_interfaces/embedding_in_tk_sgskip.py +++ b/examples/user_interfaces/embedding_in_tk_sgskip.py @@ -39,17 +39,7 @@ def on_key_press(event): canvas.mpl_connect("key_press_event", on_key_press) - -def _quit(): - root.quit() # Stops mainloop. - # The following is necessary on Windows to prevent - # Fatal Python Error: PyEval_RestoreThread: NULL tstate - root.destroy() - - -button = tkinter.Button(master=root, text="Quit", command=_quit) +button = tkinter.Button(master=root, text="Quit", command=root.quit) button.pack(side=tkinter.BOTTOM) tkinter.mainloop() -# If you put root.destroy() here, it will cause an error if the window is -# closed with the window manager. diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index a861fb85348f..54975f0c94c6 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -465,10 +465,6 @@ def resize(self, width, height): self.toolbar.configure(width=width) def show(self): - """ - this function doesn't segfault but causes the - PyEval_RestoreThread: NULL state bug on win32 - """ with _restore_foreground_window_at_end(): if not self._shown: def destroy(*args):