How do I end a Python Tkinter program? Let's say I have this code:
from Tkinter import *
def quit():
???
root = Tk()
Button(root, text="Quit", command=quit).pack()
root.mainloop()
How should I define the quit() routine?
How do I end a Python Tkinter program? Let's say I have this code:
from Tkinter import *
def quit():
???
root = Tk()
Button(root, text="Quit", command=quit).pack()
root.mainloop()
How should I define the quit() routine?
def quit()
global root
root.quit()
or
def quit()
global root
root.destroy()
The usual method to exit a Python program:
sys.exit()
(to which you can also pass an exit status) or
raise SystemExit
will work fine in a Tkinter program.