OptionMenu
The OptionMenu
element is a quirky tkinter-specific element that is similar to using a Combo
element in read-only mode. There are not as many options (no pun intended) for the OptionMenu
element compared with the Combo
element. The Combo
is the better choice if you need a feature such as an event when an item is selected.
import PySimpleGUI as sg
layout = [[sg.OptionMenu(['Option 1', 'Option 2', 'Option 3', 'Option 4'], default_value='Option 2', key='-OPTION MENU-')]]
Events
The OptionMenu
element does not generate events.
Values Dictionary
The currently chosen item is returned in the values dictionary. Note that unlike the Combo
element, a string representation of your chosen value (instead of the chosen value's original type) is returned in the values dictionary.