How to get item list from wxpython ListBox

2019-04-11 15:25发布

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()

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-04-11 15:49

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

查看更多
The star\"
3楼-- · 2019-04-11 15:57

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

[listBox.GetString(i) for i in range(listBox.GetCount())]
查看更多
登录 后发表回答