【发布时间】:2019-10-10 18:02:18
【问题描述】:
我在 python 中有一些使用 tkinter 模块的代码。我一直在尝试将函数绑定到"<Destroy>",但每次运行代码并关闭窗口时,绑定的函数都会执行 5 次。代码如下:
def bind_events(self):
''' binding the events to their functions '''
self.master.bind("<Destroy>", lambda x: print("OK"))
这段代码是一个类函数。然后我得到这个输出:
>>> OK
OK
OK
OK
OK
有没有办法解决这个问题。谢谢你的时间,对不起我的英语。
【问题讨论】:
标签: python events tkinter bind destroy