I am going through the Tk/Tkinter tutorial and
when I try to run the menubar program I get two windows instead of a menubar on one window.

Here is the code:

from tkinter import *
from tkinter import ttk
root = Tk()
root.option_add('*tearOff', FALSE)

win = Toplevel(root)
menubar = Menu(win)
win['menu'] = menubar

menubar = Menu(win)
menu_file = Menu(menubar)
menu_edit = Menu(menubar)
menubar.add_cascade(menu=menu_file, label='File')
menubar.add_cascade(menu=menu_edit, label='Edit')

menu_file.add_command(label='New', command=None)
menu_file.add_command(label='Open...', command=None)
menu_file.add_command(label='Close', command=None)

root.mainloop()

Please let me know what I am doing wrong.

- WolfShield

Too much junk in the code, try it this way ...

from tkinter import *
from tkinter import ttk

root = Tk()
root.option_add('*tearOff', FALSE)

menubar = Menu(root)
root.config(menu=menubar)
menu_file = Menu(menubar)
menu_edit = Menu(menubar)
menubar.add_cascade(menu=menu_file, label='File')
menubar.add_cascade(menu=menu_edit, label='Edit')

menu_file.add_command(label='New', command=None)
menu_file.add_command(label='Open...', command=None)
menu_file.add_command(label='Close', command=None)

root.mainloop()

GUI programming takes a while to get used to. I always hang up on the widget layouts.

This question has already been answered. Start a new discussion instead.