只需将虚拟事件绑定
<<ComboboxSelected>>到Combobox小部件:
class App: def __init__(self, parent): self.parent = parent self.value_of_combo = 'X' self.combo() def newselection(self, event): self.value_of_combo = self.box.get() print(self.value_of_combo) def combo(self): self.box_value = StringVar() self.box = ttk.Combobox(self.parent, textvariable=self.box_value) self.box.bind("<<ComboboxSelected>>", self.newselection) # ...
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)