I'm learning Tkinter using a tutorial and the menu isn't appearing. I've found a few other examples of this happening, but they all appear to be Mac or simple typos. Here's my minimum example:
from tkinter import *
# Create the root window
root = Tk()
root.title("DebugExample")
# Menu bar
menu_bar = Menu(root)
item = Menu(menu_bar)
item.add_command(label='New')
item.add_cascade(label='File', menu=item)
root.config(menu=menu_bar)
# Task name label
lTaskName = Label(root, text = "Just some text to give content for the window")
lTaskName.grid()
# Run the main loop
root.mainloop()
I can see that there's an extra line below the title that's not there if I take out the menu code altogether so I thought perhaps it was a spacing thing, but I can't drag the line lower or otherwise expand it. I'm running Python 3.6.8 on RHEL 8.9 if that's helpful. Thank you!
The following line
item.add_cascade(label='File', menu=item)
should be changed to
menu_bar.add_cascade(label='File', menu=item)