
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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.
Example
from tkinter import * win =Tk() win.geometry("700x300") label= Label(win, text= "Select any One Language!", font= ("", 10)) label.pack(pady=30) #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") main_menu.pack() win.mainloop()
Output
Running the above code will create a dropdown Menu.
- Related Articles
- Tkinter dropdown Menu with keyboard shortcuts
- How can I create a dropdown menu from a List in Tkinter?
- Add dropdown menu to buttons using Bootstrap
- Creating a Navigation Menu using CSS Image Sprite
- Right align a Bootstrap dropdown menu
- Create Dropdown menu with Bootstrap
- Creating a prompt dialog box using Tkinter?
- Creating a table look-a-like using Tkinter
- Creating scrollable Listbox within a grid using Tkinter
- How to create a hoverable dropdown menu with CSS?
- Creating a tkinter GUI layout using frames and grid
- How to avoid dropdown menu to close menu items on clicking inside?
- Add headers inside the dropdown menu in Bootstrap
- How to create a clickable dropdown menu with CSS and JavaScript?
- How to create a mega menu (full-width dropdown menu in a navigation bar) with HTML and CSS?

Advertisements