1.创建
from tkinter import *
root=Tk()
v=StringVar()
v.set('xs')
om=OptionMenu(root,v,'Python','PHP','CPP','C')
om.pack()
root.mainloop()
2.打印值
from tkinter import *
root=Tk()
v=StringVar()
v.set('xs')
def printOption(event):
print(v.get())
om=OptionMenu(root,v,'Python','PHP','CPP','C')
om.bind('<Button-1>',printOption)
om.pack()
root.mainloop()