Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在将 tkinter 用于 gui python。我想在按下按钮 X 时添加方法,我的意思是当我单击“X”按钮时,它说再见(不是对话框)然后退出
我不知道这个示例是否会回答您的问题:
from tkinter import * master = Tk() def callback(): text= Label(master, text="Bye").pack() master.destroy() b = Button(master, text="X", command=callback) b.pack() mainloop()
但是我们没有时间看 'Bye'... 看到它,我们应该添加倒计时以在 x 秒后执行销毁(阅读:after())