如何在ttk Python33中将值更新到组合框下的列表框 [英] How to update values to the listbox under Combobox in ttk Python33
本文介绍了如何在ttk Python33中将值更新到组合框下的列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建组合框时,列表中没有任何项目。现在,当我单击下拉按钮时,将调用一个函数(通过postcommand选项),但是一旦在函数中,我便不知道如何在组合框的列表框中设置值。
When I create the Combobox, it has no items in the list. Now when I click on the dropdown button a function is called (via the postcommand option), but once in my function I don't know how to set the values in the listbox of the 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
谢谢
Harvey
推荐答案
回答了我自己的问题。
我终于找到了一个有用的示例,并使其与以下代码一起使用:
I Finally found an example that helped, and got it to work with the following code:
#update list upon drop down
self.cbox = Combobox(self, width = 10, postcommand = self.updtcblist)
def updtcblist(self):
list = self.getPortLst()
self.cbox['values'] = list
此功能可根据需要工作。
This works as desired.
这篇关于如何在ttk Python33中将值更新到组合框下的列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文