Creating a Dropdown Menu using Tkinter

Navigation is the most important part of any application, as it improves the user experience in an aesthetic way. Using Tkinter, we can create menus and submenus very efficiently.

Tkinter has an inbuilt function to create menus and these can be invoked with another tkinter widget or window. Tkinter.Menu module provides some properties in Menu-items. Some of these properties are used to label the buttons, toggling the button, adding submenus using cascade properties, etc.

In this article, we will see how to create a dropdown menu using tkinter.Menu and its Menu-item properties. We will use OptionMenu widget to create a list of options and related commands.


from tkinter import *
win =Tk()
label= Label(win, text= "Select any One Language!", font= ("", 10))

#Access the Menu Widget using StringVar function
clicked= StringVar()
#Create an instance of Menu in the frame
main_menu = OptionMenu(win, clicked, "C++", "Java", "Python", "Rust","Go","Ruby")



Running the above code will create a dropdown Menu.

Updated on: 04-Mar-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started