Reputation: 160
When pressing the button from the code below the window freezes and the spinning ball of death appears. Same issue arises with quit
. I'm running python 3.7 with tk version 8.6 on MacOS 10.14.3.
import tkinter as tk
root = tk.Tk()
tk.Button(root, text="Quit", command=root.destroy).pack()
root.mainloop()
Any suggestions?
Upvotes: 2
Views: 2192
Reputation: 31
root.quit is what you should use to close the main (root) window of your application.
the issues you are seeing are likely because you are running your code from an IDE. [such as Spyder for instance, which I happen to know first-hand hangs tkinter applications on root.quit()]
run your program from a terminal prompt, and you should have no issues.
IMPORTANT: Also, be sure you are using tk version 8.6.8, as version 8.6.9 has known issues with MacOS 10.14 Mojave. https://bugs.python.org/issue35402 https://bugs.python.org/issue35485
Upvotes: 3