【问题标题】:Exit program within a tkinter classtkinter 类中的退出程序
【发布时间】:2020-09-11 06:54:53
【问题描述】:

代码:

from tkinter import *

class GUI(Tk):
    def __init__(self):
        super().__init__()
        self.protocol("WM_DELETE_WINDOW", self.closing)

    def closing(self):
        self.destroy()

但是当关闭窗口时,程序并没有停止,这就是控制台打印的内容:

在执行“21317232closure”时(“WM_DELETE_WINDOW”窗口管理器协议的命令)

这是什么意思,有没有办法解决这个问题?

【问题讨论】:

标签: python tkinter


【解决方案1】:

你是如何开始这段代码的?我添加了几行,它对我来说没有错误。

from tkinter import *

class GUI(Tk):
    def __init__(self):
        super().__init__()
        self.protocol("WM_DELETE_WINDOW", self.closing)

    def closing(self):
        self.destroy()


app = GUI()
app.mainloop()

【讨论】:

    猜你喜欢
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    • 2012-12-21
    • 2019-10-04
    • 2018-11-26
    • 1970-01-01
    • 2017-01-13
    • 2011-07-22
    相关资源
    最近更新 更多