当我创建组合框时,列表中没有项目。现在,当我单击下拉按钮时,会调用一个函数(通过 postcommand 选项),但是一旦在我的函数中,我不知道如何在组合框的列表框中设置值。
代码如下:
#update list upon drop down
self.cbox = Combobox(self, width = 10, postcommand = self.updtcblist)
def updtcblist(self):
list = self.getPortLst()
self.cbox.getlistbox.set(list) #getlistbox doesn't work
谢谢,
哈维
最佳答案
回答了我自己的问题。
我终于找到了一个有帮助的例子,并让它与以下代码一起工作:
#update list upon drop down
self.cbox = Combobox(self, width = 10, postcommand = self.updtcblist)
def updtcblist(self):
list = self.getPortLst()
self.cbox['values'] = list
这按需要工作。
关于combobox - 如何将值更新到 ttk Python33 中 Combobox 下的列表框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18906047/