The Wayback Machine - http://web.archive.org/web/20230609105222/https://www.geeksforgeeks.org/python-tkinter-menubutton-widget/amp/

Python Tkinter – Menubutton Widget

Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to create the GUI applications. Creating a GUI using tkinter is an easy task.

Note: For more information, refer to Python GUI – tkinter

Menubutton widget

The Menubutton widget can be defined as the drop-down menu that is shown to the user all the time. The Menubutton is used to implement various types of menus in the python application.

Syntax:

w = Menubutton ( master, options )

Parameters:

Options:
Following are commonly used Option can be used with this widget :-

Example:




from tkinter import *
  
root = Tk()
root.geometry("300x200")
  
w = Label(root, text ='GeeksForGeeks', font = "50") 
w.pack()
  
menubutton = Menubutton(root, text = "Menu")   
    
menubutton.menu = Menu(menubutton)  
menubutton["menu"]= menubutton.menu  
  
var1 = IntVar()
var2 = IntVar()
var3 = IntVar()
  
menubutton.menu.add_checkbutton(label = "Courses",
                                variable = var1)  
menubutton.menu.add_checkbutton(label = "Students",
                                variable = var2)
menubutton.menu.add_checkbutton(label = "Careers",
                                variable = var3)
    
menubutton.pack()  
root.mainloop()

Output:


Article Tags :