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 results-driven tech professional with 8+ years of experience in web and mobile development, leadership, and emerging technologies.
After completing his Master’s in Computer Applications (MCA), he began his journey as a programming mentor, guiding 100+ students and helping them build strong foundations in coding. In 2019, he founded Owlbuddy.com, a platform dedicated to providing free, high-quality programming tutorials for aspiring developers.
He then transitioned into a full-time programmer, where his hands-on expertise and problem-solving skills led him to grow into a Team Lead and Technical Project Manager, successfully delivering scalable web and mobile solutions. Today, he works with advanced technologies such as AI systems, RAG architectures, and modern digital solutions, while also collaborating through a strategic partnership with Technobae (UK) to build next-generation products.
