|

楼主 |
发表于 2021-5-12 09:54:45
|
显示全部楼层
本帖最后由 秋月明 于 2021-5-12 09:56 编辑
#设置“朝向”列表框
label_orient = Label(frame_prehouse,text="朝向:",font=("宋体",15))
label_orient.grid(row=2,columnspan=2,sticky=W,padx=160,pady=20)
Orient = StringVar()
list_orient = ttk.Combobox(frame_prehouse, textvariable=Orient, state='readonly', width=12)
list_orient.grid(row=2,columnspan=2,sticky=E)
value = ['东', '东北', '东南', '北', '南', '西', '西北', '西南']
list_orient["value"] = ( '东', '东北', '东南', '北', '南', '西', '西北', '西南')
list_orient.current(0)
def getorient(*args):
print(list_orient.current())
list_orient.bind("<<ComboboxSelected>>", getorient)
就是返回一个顺序,比如我点击了东南,我需要返回一个3;我需要的是 点击列表框里任意选项后就直接得到对应的数字,不用按钮 |
|