adi*_*wat 2 user-interface tkinter python-3.x
我目前正在学习 python tkinter,并且有一个关于使用显式代码退出 tkinter 窗口的问题。到目前为止,这是我的代码(我已将其简化以仅关注问题)
from tkinter import *
def DoSomething():
    pass
root = Tk()
men = Menu(root)
root.config(menu = men)
submenu = Menu(men)
men.add_cascade(label = "File",menu = submenu)
submenu.add_command(label = "quit",command = Menu.quit)#Window does not close when user clicks "quit",
                                                       it just 
                                                       stays there non-responding
root.mainloop()
任何与此相关的帮助将不胜感激。谢谢
在 python tkinter 中,你应该使用“destroy”方法来删除 tkinter 窗口,即:
submenu.add_command(label="quit",command=root.destroy)
就你而言。
| 归档时间: | 
 | 
| 查看次数: | 976 次 | 
| 最近记录: |