Hi all,
python version:3.7
wxpython version:4.0.6
platform:windows 10.0
Some Erroe occured when i use the wx.CheckListBox.
I use the EVT_CHECKLISTBOX event.
Errors just like this:
e1 = event.GetCheckedItems()
AttributeError: ‘CommandEvent’ object has no attribute ‘GetCheckedItems’
items = [i for i in range(event.GetCount()) if event.IsChecked(i)]
AttributeError: ‘CommandEvent’ object has no attribute ‘GetCount’
and:
event.GetSelection() can work but event.GetSelections() raise an error:
e1 = event.GetSelections()
AttributeError: 'CommandEvent' object has no attribute 'GetSelections'
I have perplexed for a few days.
Does anyone have any ideas why this might be happening?
Yes, those are the wx.CheckListBox methods, but the parameter passed to the event handler is a wx.CommandEvent object, not a wx.CheckListBox.
Somewhere in your code you have something like this:
something = wx.CheckListBox(...)
If you’re not already doing it, you need to save the something reference as an attribute of self, or give yourself some other way to access it later. Then in the event handler you can call the checked methods like: