【发布时间】:2020-05-17 11:54:29
【问题描述】:
您好,我有以下代码
def create(self):
geo = StringVar()
city = ttk.Combobox(gui, textvariable=geo,state="readonly")
city.config(values=self.geo)
city.pack()
city.bind("<<ComboboxSelected>>", self.cityselection)
def cityselection(self,event):
selected=event
print(selected)
我想将 Combobox 中的选定值发送到 cityselection 函数,但是当我打印它时,我只得到
VirtualEvent 事件 x=0 y=0
不管我选择哪个值,我总是会得到上述输出状态,例如:伦敦或多伦多,
【问题讨论】:
-
在这两种方法中都使用
self.geo来访问选定的元素。