Python 3 does not give a clean exit
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("quitti开发者_开发问答ng")
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...?
精彩评论