2020
09-24
09-24
Python 窗体(tkinter)下拉列表框(Combobox)实例
废话不多说,看代码吧!importtkinterfromtkinterimportttkdefgo(*args):#处理事件,*args表示可变参数print(comboxlist.get())#打印选中的值win=tkinter.Tk()#构造窗体comvalue=tkinter.StringVar()#窗体自带的文本,新建一个值comboxlist=ttk.Combobox(win,textvariable=comvalue)#初始化comboxlist["values"]=("1","2","3","4")comboxlist.current(0)#选择第一个comboxlist.bind("<<ComboboxSelected>>",go)#绑...
继续阅读 >