

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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
- Right align a Bootstrap dropdown menu
- Creating a Navigation Menu using CSS Image Sprite
- Create Dropdown menu with Bootstrap
- Creating a prompt dialog box using Tkinter?
- Creating a table look-a-like using Tkinter
- How to create a hoverable dropdown menu with CSS?
- Creating scrollable Listbox within a grid using Tkinter
- Creating a tkinter GUI layout using frames and grid
- Add headers inside the dropdown menu in Bootstrap
- Creating a Browse Button with Tkinter
- How to create a clickable dropdown menu with CSS and JavaScript?
- Creating a LabelFrame inside a Tkinter Canvas
Advertisements