Python Tkinter Menu Button

This Article covers the use of the Menu Button in Tkinter Python.

What is the Python Tkinter Menu Button?

A combination of both the button and menu widget, the Python Tkinter Menu button widget displays a drop down menu with a list of options once clicked. Otherwise it will only be showing one option.

If you haven’t been through our Tkinter Menu Article, head over there first and read more about menu’s. A menu button is just a button to which a menu is attached. Refer to the article to understand how that menu is made.

Menu Button Syntax:

MenuBttn = Menubutton(master, option..... )

Menu Buttons Options

A complete list of options for the Tkinter Menu Button. Note however, that some will only work with the newer “ttk” version. A short segment on this is included at the end of the tutorial.

1activebackgroundColor of the background when widget is under focus.
2activeforegroundColor of the foreground when widget in under focus.
3bgBackground color for the area around the widget.
4bdSize of the border around the widget. Default value is 2 pixels.
5cursorWhen the mouse is hovering over this widget, it can be changed to a special cursor type like an arrow or dot.
6direction Sets the direction of the text relative to the Menu button. Options are, LEFT, RIGHT and ‘above’.
7fgThe color for the text.
8heightThe height of the widget in terms of text lines.
9highlightcolorThe text color when the widget is under focus.
10imageUsed to display an image
11justifySpecifies how the text is aligned within the widget. One of “left”, “center”, or “right”.
12menuUsed to assign a menu object to the menu button. Allows for a list of options to be displayed.
13padxAmount of padding in terms of pixels in the left-right directions.
14padyAmount of padding in terms of pixels for the area above and below the widget.
15 reliefIt specifies the type of the border. Default is Flat, other options include RAISED and SUNKEN.
16StateDefault is NORMAL. DISABLED causes the Widget to gray out and go inactive.
17textThe text displayed next on the Menu Button.
18textvariableAllows us to assign a variable to the Menu Button. Text displayed on the Menu Button can be changed by manipulating this variable.
19widthWidth of the widget in terms of number of characters.

Menu Button Example 1.

This example explores the use of a Menu Button using a menu with Check Buttons.

Remember that the menu’s master option should always be the name of the Menu Button to which it is to be assigned. And you have to assign a menu to a Menu Button as shown in the example for it to actually display.

from tkinter import *

root = Tk()
frame = Frame(root)

MenuBttn = Menubutton(frame, text = "Favourite food", relief = RAISED)

Var1 = IntVar()
Var2 = IntVar()
Var3 = IntVar()

Menu1 = Menu(MenuBttn, tearoff = 0)

Menu1.add_checkbutton(label = "Pizza", variable = Var1)
Menu1.add_checkbutton(label = "Cheese Burger", variable = Var2)
Menu1.add_checkbutton(label = "Salad", variable = Var3)

MenuBttn["menu"] = Menu1

Tkinter widget - Menu Button

Menu Button Example 2.

This example is the same as the above one, except this time we’re using Radio buttons instead of check buttons. As expected, this causes only one option to be selected at a time.

from tkinter import *

root = Tk()
frame = Frame(root)

MenuBttn = Menubutton(frame, text = "Favourite food", relief = RAISED)

Var1 = IntVar()

Menu1 = Menu(MenuBttn, tearoff = 0)

Menu1.add_radiobutton(label = "Pizza", variable = Var1, value = 1)
Menu1.add_radiobutton(label = "Cheese Burger", variable = Var1, value = 2)
Menu1.add_radiobutton(label = "Salad", variable = Var1, value = 3)

MenuBttn["menu"] = Menu1


TTK MenuButton

The newer ttk library brings in some updated widgets which generally perform better than the originals. They offer more flexibility and have more options. Some of the above mentioned options only work with the ttk version of the Menu Button.

In the below section, we demonstrate how to do this, and we also use an option (textvariable) which is not available in the tkinter menu button.

from tkinter import *
import tkinter
from ttk import Menubutton

def f():

root = Tk()

var = StringVar()

mb = Menubutton (root, textvariable = var)
mb.pack() =  Menu ( mb, tearoff = 0 )
mb["menu"] =

b = Button(root, text = "Click", command = f)

mayoVar = IntVar()
ketchVar = IntVar() ( label="mayo",
                          variable=mayoVar ) ( label="ketchup",
                          variable=ketchVar )


This marks the end of our Python Tkinter Menu Button article. You can head back to the main Tkinter article using this link. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the article tutorial content can be asked in the comments section below.

Notify of
Newest Most Voted
Inline Feedbacks
View all comments
Tyler R Parker

Dude, a lot of the parameters listed on this tutorial do not actually work when you write them into the code. For example, textvariable can’t go inside an .add(type, option) to a menu object, and neither can it go into the Menu() widget creation. This isn’t the only tutorial on this website with these mistakes! I have to try out every single parameter and half of them don’t work. Please clean this up!