如何从 wxpython ListBox 获取项目列表
问题描述
是否有一个方法可以返回 wxPython listBox 中包含的项目列表?
Is there a single method that returns the list of items contained in a wxPython listBox?
我似乎在文档中的任何地方或任何地方都找不到任何东西.我能想到的就是将选择设置为所有项目,然后获取选定的项目,尽管这似乎是一种丑陋的迂回方式来做一些应该简单的事情.
I cant seem to find anything anywhere in the documentation or anywhere for that matter. All that I can think to do is to set the selection to all of the items and then get the selected items, though seems like an ugly roundabout way of doing something that should be simple.
更新:
正如 jeremy 所指出的,这样做的方法是使用 GetStrings()
As pointed out by jeremy the way to do this is with GetStrings()
例如
listBoxList = yourListBox.GetStrings()
解决方案
wx.ListBox
派生自 wx.ControlWithitems
.我认为 GetStrings() 是您所需要的.
wx.ListBox
is derived from wx.ControlWithitems
. I think GetStrings() is what you need.
相关文章