我正在尝试创建一些帧,以便通过使用菜单小部件进行访问。当使用菜单时,你可以点击其中一个命令-它会弹出一个框架,菜单小部件应该仍然在顶部,所以你可以很容易地决定去哪里。在
我试图在一个函数中使用optionmenu小部件,这个函数是在登录页面之后调用的,因此我使用了其中的顶层方法。当我尝试做这个选项菜单时,我遇到了一些问题,我现在被卡住了,也不明白代码有什么问题,所以我希望有人能告诉我它有什么问题。在
CoreContent=命名的函数
myGUI=主根
def CoreContent():
#Building core content/structure
myGUI.withdraw() # This is the main root that I remove after user logs in
CoreRoot = Toplevel(myGUI, bg="powderblue") # Toplevel
CoreRoot.title("titletest")
CoreRoot.geometry('300x500')
CoreRoot.resizable(width=False, height=False)
#Creating drop-down menu
menu = Menu(CoreRoot)
CoreRoot.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="test one", command=lambda: doNothing()) # Problem
filemenu.add_command(label="soon")
filemenu.add_separator()
filemenu.add_command(label="Exit")
我很困惑我应该如何以及在哪里创建要添加的框架,作为在选项菜单小部件中使用的命令。在
有关如何在Tkinter中的帧之间切换的清晰说明,请查看以下链接:Switch between two frames in tkinter
要从菜单中执行此操作,可以写下以下内容:
相关问题 更多 >
编程相关推荐