Tkinter

Menubutton Tkinter | Python 3

In this tutorial, we are going to see how to use Menubutton in Tkinter. The Menubutton widget is part of a drop-down menu that remains on the screen at all times. Each Menubutton is associated with a Menu widget that can display the choices for that Menubutton when the user clicks it.
 


 
 

Syntax:

Here is the syntax to create this widget:

menu = Menubutton ( master, option = value, ... )

 

Parameters:
  • master : This represents the parent window.
  • options : See below for a list of the most commonly used options for this widget. These options can be used as comma separated key-value pairs.

 

 

Example:
from tkinter import *
  
gui = Tk() 
gui.geometry("150x150") 
  
menuBtn = Menubutton(gui, text = "Menu")    
    
menuBtn.menu = Menu(menuBtn)   
menuBtn["menu"] = menuBtn.menu   
  
v1 = IntVar() 
v2 = IntVar() 
v3 = IntVar() 
  
menuBtn.menu.add_checkbutton(label = "Copy", variable = v1)   
menuBtn.menu.add_checkbutton(label = "Paste", variable = v2) 
menuBtn.menu.add_checkbutton(label = "Close", variable = v3) 
    
menuBtn.pack()   
gui.mainloop()

Output:


 
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *