In this tutorial, we will learn about Python Tkinter MenuButton. Tkinter MenuButton is a widget which we use to show the drop-down menu on the screen. We use a Menu widget with this MenuButton to show options to the user to select from.
Page Contents
Syntax to add Python Tkinter MenuButton
w = Menubutton (master, options)
- master: This represents the parent window.
- options: Here is the list of most commonly used options for this widget.
Example Program of Python Tkinter MenuButton
from tkinter import *
mainWindow = Tk()
mainWindow.geometry("300x150")
menuButton= Menubutton (mainWindow, text="Select Language", relief=RAISED )
menuButton.grid()
menuButton.menu = Menu ( menuButton, tearoff = 0 )
menuButton["menu"] = menuButton.menu
pythonVar = IntVar()
javaVar = IntVar()
menuButton.menu.add_checkbutton ( label="Python",
variable=pythonVar )
menuButton.menu.add_checkbutton ( label="Java",
variable=javaVar )
menuButton.pack()
mainWindow.mainloop()
Various possible options in Python Tkinter MenuButton:
| Option | Description |
|---|---|
| activebackground | This option is used to set background color of widget under focus. |
| activeforeground | This option is used to set foreground color of widget under focus. |
| anchor | This option helps us to set position of text inside the widget. By default value of anchor is CENTER. |
| bg | This option helps us to set normal background color of widget. |
| bd | This option helps us to set the border size around widget. |
| cursor | This option helps us to set the style of cursor like an arrow, dot etc. |
| direction | This option is used to set the position of menu to display such as LEFT, RIGHT, or ABOVE. |
| disabledforeground | This option is used to disable text color of widget. |
| fg | This option helps us to set normal foreground colour of widget. |
| height | This option helps us to set height of widget. |
| highlightcolor | This option is used to set highlight color shown to the widget under focus. |
| justify | This helps us to automatically organize the text in multiple lines. |
| menu | This option is used to set menu with MenuButton. |
| padx | This option helps us to set space left and right of widget. |
| pady | This option helps us to set space above and below of widget. |
| relief | This helps us to set the style of the border by which is default Flat. |
| state | This option is used to set state of MenuButton such as ENABLE or DISABLE. |
| text | This option helps us to set string source for label. |
| underline | This option helps us to underline specified letter of the text. |
| width | This helps us to set the width of the widget in characters. By default it is 20. |

Parvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​
