简体   繁体   中英

Dropdown menu in Python Tkinter

I am new to 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 *

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM