Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Python » Tkinter » OptionMenu

OptionMenu Example in Python Tkinter


from tkinter import *
from PIL import ImageTk, Image

root = Tk()
root.title('Example of Drop Down in Python/tkinter')
#root.iconbitmap('c:/img.ico')
root.geometry("400x350")


def func():
    label = Label(root, text=clicked.get()).pack()

options = ["Yellow", "Green", "Red"]

clicked = StringVar()
clicked.set("Yellow")

dropdown = OptionMenu(root, clicked, *options)
dropdown.pack()

button = Button(root, text="Show", command=func).pack()

root.mainloop()
how to create optino menu in Python Tkinter