#Option Menu demonstration from tkinter import * class OptionMenuDemo: def __init__(self, aWindow): #A list of string options for the optionMenu OPTIONS = ["CS 1301", "CS 2316", "CS 4400"] self.sv = StringVar() #Set CS4400 to be the default self.sv.set(OPTIONS[2] ) #The asterisk (star) in front of OPTIONS unpacks #the list into individual arguments. om = OptionMenu( aWindow, self.sv, *OPTIONS, command=self.optionChanged) om.pack() self.entry = Entry(aWindow,textvariable=self.sv) self.entry.pack() def optionChanged(self, theString): print("The option changed!") print("self.sv value is:", self.sv.get() ) print("Passed String is:", theString) mainWin = Tk() app = OptionMenuDemo(mainWin) mainWin.mainloop()