是否可以“设置”组合框的列表,wxpython?
您好,我知道可以使用列表来执行此操作,但是可以使用组合框执行此操作吗?有没有类似set的函数?
我尝试将 set 与组合框一起使用,但收到以下错误: AttributeError:“ComboBox”对象没有属性“Set”,
谢谢。
Hi i know its possible to do this with lists however is it possible to do this with Comboboxes? Is there anything similar to the set function?
I have tried using set with a Combo box but i receive the following error:
AttributeError: 'ComboBox' object has no attribute 'Set'
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
那么,您可以调用 SetItems(myList) 将列表放入 ComboBox 中,覆盖其中已有的内容。
编辑:在组合框的列表中创建列表的最常见方法如下:
但由于 ComboBox 继承自 ItemContainer,因此您也可以像这个完整示例一样执行此操作:
Well, you can call SetItems(myList) to put a list into a ComboBox, overwriting what's already in it.
EDIT: The most common method to create a list in a combobox's list is like this:
But since ComboBox inherits from ItemContainer, you can also do it like this complete example:
http://www.wxpython.org/docs/api/wx.ComboBox -class.html
http://www.wxpython.org/docs/api/wx.ComboBox-class.html
我相信您正在寻求一种“在运行时”添加新项目的方法?即创建表单后?如果是这样,请参阅下面的代码;-)
本质上,您不应该使用 ComboBox 的 Clear() 和 Append() 方法,以及从某处的事件调用该函数的事实。希望这是您正在寻找的。
I believe your are asking for a method to add new items "at runtime"? ie after the form is created? See the code below if so ;-)
In essence what you should not is the Clear() and Append() methods of the ComboBox and the fact that this function is called from an event somewhere. Hope it is what you are looking for.