Interference tkinter and plot from matplotlib

Pierre Bonville pierre.bonville49 at gmail.com
Wed Sep 30 09:46:39 EDT 2020


 Hi everybody,
I am running this little program below on Win 10 with Python 3.8 (just
typing prog.py after the prompt c:\Users ...>), and while it correctly
displays the window and does the first plt.plot(), it does not reach the
input command and remains waiting after I shut the plot. If I replace
'quit' by 'destroy' in the button command, it works correctly. I looked on
various Python forums on the Net, but didn't find an answer.
Regards,
P.Bonville

import tkinter as tk
import matplotlib.pyplot as plt
r = tk.Tk()
b = tk.Button(r, text= r.quit)
b = tk.Button(r, text='quit', command=r.quit)
b.pack()
r.mainloop()  # This blocks until press button.
# Root window with button is still displayed.
plt.plot()
plt.show()
rep = input("Return")
plt.plot()
plt.show()


More information about the Python-list mailing list