Cannot Understand How To Get Data From Checklistbox In Wxpython
I am trying to get either the strings checked or the integers from a check list. I cannot seem to get it anywhere. In the code below, you'll see a bunch of un-commented code, those
Solution 1:
checkedItems = [i for i in range(citList.GetCount()) if citList.IsChecked(i)]
citList.GetChecked()
should have also completed the task for you. May the problem be that you are trying to get selected items in __init__
?
Upd.: You do not want to get checked items during __init__
- they cannot be checked by the user at that moment. You'd better check them in any event handler, e.g. wx.EVT_BUTTON
.
Try writing self
more often, e.g.:
self.citList = wx.CheckListBox(self, -1, (60, 50), wx.DefaultSize, allLoc)
# some codeself.panel = citPanel(self, -1)
and change Clicked
to:
defClicked(self, event):
checkedItems = [i for i inrange(self.panel.citList.GetCount()) if self.panel.citList.IsChecked(i)]
print checkedItems
event.Skip()
Hope this helps.
Post a Comment for "Cannot Understand How To Get Data From Checklistbox In Wxpython"