1

I'm trying to do a menu using tkinter. But when I run the code, the window appears, but the menu doesn't. I'm getting no errors.

Here is my code:

from tkinter import *

root = Tk()
root.geometry("500x300")

menu = Menu(root)

file_menu = Menu(menu, tearoff=0)
file_menu.add_command(label="New")
file_menu.add_command(label="Open")
file_menu.add_command(label="Save")

menu.add_cascade(label="File", menu=file_menu)
menu

root.mainloop()
martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

2

You haven't added it to the root window. You need to do the following after creating menu:

root.configure(menu=menu)
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685