开发者

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...?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜