Tkinter OptionMenu Tutorial
OptionMenu can be translated as a drop-down list from which the user can select an item, and it is constructed as follows.
OptionMenu(master, options, *value)
where *value is a series of drop-down lists.
Example#1
Create OptionMenu, this drop-down list has three data, Python, Java, and C.
from tkinter import *
root = Tk()
root.title("apidemos.com")
root.geometry("300x180")
var = StringVar(root)
optionmenu = OptionMenu(root,var,"Python","Java","C")
optionmenu.pack()
root.mainloop()
Output:
The OptionMenu is empty when the program is executed, because no option is selected. The options will change when either one is selected.
You can note the way the OptionMenu drop-down list item is created in line 8 above.