[英]Dropdown menu in Python Tkinter
I am new to Python Gui Tkinter. 我是Python Gui Tkinter的新手。 I was making an application in which one window has a drop down menu. 我正在制作一个窗口包含下拉菜单的应用程序。 The code is below, but it is not executing. 该代码在下面,但未执行。 It just opens a window but no menu. 它只是打开一个窗口,但没有菜单。 What is the issue with the code? 代码有什么问题? I have tried multiple times. 我已经尝试了多次。 Can anybody suggest how should I proceed? 有人可以建议我应该如何进行吗?
from Tkinter import *
root = Tk()
root.title("Data Entry Window")
menu = Menu(root)
root.config(menu = menu)
subMenu = Menu(menu)
menu.add_cascade(label = "Entry", menu = subMenu)
subMenu.add_command(label = "New Entry")
subMenu.add_separator()
subMenu.add_command(label = "Update Entry")
subMenu.add_separator()
subMenu.add_command(label = "Delete Entry")
editMenu = Menu(menu)
menu.add_cascade(label = "Report", menu = editMenu)
editMenu.add_command(label = "Day Report")
editMenu.add_separator()
editMenu.add_command(label = "Range Report")
root.mainloop()
You write 你写
from Tkinter import *
This is wrong. 错了 The problem will solved if you write it like this: 如果您这样编写,该问题将得到解决:
from tkinter import *
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.