0

Tried searching for this and could not find a suitable answer. I know we can do the following to create a menu to the root window in tkinter

menu = Menu(root)
some_menu = Menu(menu, ....)
some_menu.add_command(label = some text, command = some command) 
....
menu.add_cascade(label = some title, menu = some_menu)
root.config(menu = menu)

now let's say that we passed some_menu to the root config instead then it would display the cascade menu's options / children horizontally across the top bar of the the tkinter window where the menu's appear and we could make multiple menu's this way by creating sub menu's of these options but this seems a bit convoluted.

That being said is there a way to create multiple menu's beside each other? I tried creating a new menu as above and just passing the new menu to root.config

another_menu = Menu(root)
options = Menu(another_menu, ....)
options.add_command(label = some label, command = some command)
another_menu.add_cascade(label = some text, menu = options)
root.config(menu = another_menu)

as well however the program / script gets stuck whenever this is added and doesn't run I'm assuming that's some sort of memory leak? Which would make sense, but I don't see another way to do this.

3
  • Are you wanting to create more than one menu bar? Can you please write the smallest complete program possible that illustrates the program "getting stuck"? It's not due to some sort of memory leak, but without seeing actual code it's impossible to guess from your description. Commented Mar 25, 2015 at 10:39
  • Yes as an create additional menus beside each other in the menu bar like the first code block above I don't know how to write a smaller code example than the one provided that's the simplest example I could provide that would get stuck. Commented Mar 25, 2015 at 12:23
  • The simplest code includes the import and other code, to make a complete running example. Commented Mar 25, 2015 at 12:52

1 Answer 1

2

You can have only a single menubar at the top of an application. This menubar can have as many child ("cascade") menus on it that will fit on the screen. On some platforms, you can also add commands to the top menubar, but from a usability standpoint that is a bad idea.

Sign up to request clarification or add additional context in comments.

2 Comments

it is possible to have another menu in a Toplevel
@nda: yes, it is possible to add a menu to a Toplevel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.