开发者

Python 3 does not give a clean exit

开发者 https://www.devze.com 2023-03-07 20:34 出处:网络
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.

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

精彩评论

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