combobox - 如何将值更新到 ttk Python33 中 Combobox 下的列表框

标签 combobox tkinter python-3.3 ttk

当我创建组合框时,列表中没有项目。现在,当我单击下拉按钮时,会调用一个函数(通过 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/

相关文章:

javascript - 获取ExtJS中数据存储的某个值

Python错误: Couldn't read from RWops

python - 在 Python 3.3 中解方程

python - 将 Tkinter GUI 分成单独的模块 (Python 3.4)

python - 相当于允许 'from module import *' 的 label 或 goto

python - 获取输入时解析错误时出现意外的 EOF

delphi - 组合框中的名称值对

javascript - 在 JavaScript 中显示 Combobox 项目的文本 onchange()

c# - ComboBox SelectedItem 未设置 x :Bind

python - 为什么我的按钮不适用于 Tkinter 计算器?