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

Har*_*vey 4 combobox tkinter ttk python-3.3

当我创建Combobox时,它没有列表中的项目.现在,当我点击下拉按钮时,会调用一个函数(通过postcommand选项),但是在我的函数中,我不知道如何在Combobox的列表框中设置值.

代码如下:

    #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
Run Code Online (Sandbox Code Playgroud)

谢谢,

哈维

Har*_*vey 10

回答了我自己的问题.

我终于找到了一个帮助的例子,并使用以下代码:

#update list upon drop down
self.cbox = Combobox(self, width = 10, postcommand = self.updtcblist)

def updtcblist(self):
    list = self.getPortLst()
    self.cbox['values'] = list
Run Code Online (Sandbox Code Playgroud)

这可以按预期工作.