This code does not give a clean exit when the Exit button is clicked. Instead, it hangs, leaaving the dead GUI. Hw can we fix this? A similar program in Python 2 behaves nicely.
from tkinter import *
import sys
root=Tk()
def quit():
sys.exit("quitting")
frame=Frame()
frame.pack()
x=Label(root,text='Label')
x.pack()
y=Button(root,text='Button')
y.pack()
z=Button(root,text='Exit',command=quit)
z.pack()
root.mainloop()
def quit():
root.destroy()
Should work...?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.