【问题标题】:Why root.quit doesnt close the program? [duplicate]为什么 root.quit 不关闭程序? [复制]
【发布时间】:2020-11-05 14:26:21
【问题描述】:

我正在尝试添加一个按钮来关闭我的应用程序,但典型的 root.quit 似乎不起作用,我不明白为什么?

代码如下:

root = Tk()
root.title("Fahrkartenautomat")
root.iconbitmap("E:\pyth\ka.ico")
wk = Label(root, text="Willkommen!")

ksb = Button(root, text="Kurzstraeke", state=NORMAL, command=ksc(KS,s))
tkb = Button(root, text="Tageskarte", state=NORMAL, command=tkc(TG,s))
mkb = Button(root, text="Monatskarte", state=NORMAL, command=mkc(MK,s))
jkb = Button(root, text="Jahreskarte", state=NORMAL, command=jkc(JK,s))
wt= Button(root, text="Weiter", fg="#00AA00", state=NORMAL)
exb= Button(root, text="Schliessen", fg="#FF0000", bg="#000000", state=NORMAL, command=root.quit)

【问题讨论】:

标签: python tkinter


【解决方案1】:
root.quit()

仅绕过根窗口,但仍会在后台运行。要退出窗口,您必须使用

root.destroy()

【讨论】: