How to get item list from wxpython ListBox

安稳与你 提交于 2020-01-01 14:35:19

问题


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.

Update:

As pointed out by jeremy the way to do this is with GetStrings()

e.g.

listBoxList = yourListBox.GetStrings()


回答1:


wx.ListBox is derived from wx.ControlWithitems. I think GetStrings() is what you need.




回答2:


You can get a list of the strings in the listbox like:

[listBox.GetString(i) for i in range(listBox.GetCount())]


来源:https://stackoverflow.com/questions/3229749/how-to-get-item-list-from-wxpython-listbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!