1from Tkinter import *
2
3master = Tk()
4
5variable = StringVar(master)
6variable.set("one") # default value
7
8w = OptionMenu(master, variable, "one", "two", "three")
9w.pack()
10
11mainloop()
12
1from tkinter import *
2from tkinter import ttk
3
4screen = Tk()
5
6my_weekdays_names = ["MONDAY","TUESDAY","WENSDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY"]
7
8def weekdaySelection(event):
9 for x in range(7):
10 if weekdaysDropdown.get() == my_weekdays_names[x]:
11 print(my_weekdays_names[x])
12
13
14weekdaysDropdown = ttk.Combobox(screen, values = my_weekdays_names)
15weekdaysDropdown.current(1)
16weekdaysDropdown.bind("<<ComboboxSelected>>", weekdaySelection)
17weekdaysDropdown.grid()