Hide or removing a menubar of tkinter in python Hide or removing a menubar of tkinter in python tkinter tkinter

Hide or removing a menubar of tkinter in python


Is this what you're looking for:

from tkinter import *root = Tk()menubar = Menu(root)root.config(menu=menubar)submenu = Menu(menubar)menubar.add_cascade(label="Submenu", menu=submenu)submenu.add_command(label="Option 1")submenu.add_command(label="Option 2")submenu.add_command(label="Option 3")def remove_func():    menubar.delete(0, END)remove_button = Button(root, text="Remove", command=remove_func)remove_button.pack()

?


Another way is:

from tkinter import *root = Tk()menubar = Menu(root)root.config(menu=menubar)submenu = Menu(menubar)menubar.add_cascade(label="Submenu", menu=submenu)submenu.add_command(label="Option 1")submenu.add_command(label="Option 2")submenu.add_command(label="Option 3")def remove_func():    emptyMenu = Menu(root)    root.config(menu=emptyMenu)remove_button = Button(root, text="Remove", command=remove_func)remove_button.pack()

What's different:
in

def remove_func():

created an empty menu

emptyMenu = Menu(root)

and replaced it with the current menu (menubar)

root.config(menu=emptyMenu)


Just FYI, I know this question is old and has an accepted answer but this worked for me on tkinter version 8.6 Python 3

my_tk.config(menu="")

For some reason an empty string works but not None