Reputation: 495
I'm confused as to how to dynamically get the change of each box item state. I couldn't understand either how to bind an event to one particular box being checked in the checkboxlist.
The purpose is that I have several boxes representing parameters:
A, B, C, D, E, All
'All' is by default activated, and I would like that if another box is checked, then 'All' gets unchecked automatically.
How would I go about doing that ?
self.list_choice = ['A', 'B', 'C', 'D', 'E', 'All']
pos = (5, 20)
self.list_param = wx.CheckListBox(self, wx.ID_ANY, pos, wx.DefaultSize,
self.list_choice, style=1)
self.list_param.Check(5, True)
I am not able to register a change of the list when one happens, only to read the list once when another event ('Start') is called.
Upvotes: 0
Views: 1738
Reputation: 12693
Why not bind your list_param
to a wx.EVT_CHECKLISTBOX
event, which unchecks All
in case anything else is checked, like this?
self.Bind(wx.EVT_CHECKLISTBOX, self.check_list_param, self.list_param)
def check_list_param(self, evt):
checked = self.list_param.GetChecked()
if len(checked) > 1 and 5 in checked:
self.list_param.Check(5, check=False)
Upvotes: 1