I am using the CheckListCtrlMixin to let a user enable and disable plugins for my application. I would like to update my internal model as soon as the user checks/unchecks an item in the list. What event is emitted by the CheckListCtrlMixin when an item is checked?
class CheckListCtrl(wx.ListCtrl,
CheckListCtrlMixin, ListCtrlAutoWidthMixin):
def __init__(self, parent):
wx.ListCtrl.__init__(self, parent, -1,
style=wx.LC_REPORT | wx.SUNKEN_BORDER)
CheckListCtrlMixin.__init__(self)
ListCtrlAutoWidthMixin.__init__(self)
Neither of the following emit when an item is checked or unchecked:
self.pluginlist = CheckListCtrl(win)
... add a bunch of items to the list ...
self.pluginlist.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_item_activated)
self.pluginlist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_item_selected)
CheckListCtrlMixin
does not emit an event for un/checking an item. Instead, it calls the overridable method:
def OnCheckItem(self, index, flag):
"flag is True if the item was checked, False if unchecked"
pass
To 'bind' the 'event' outside your CheckListCtrl
class, you can use:
self.pluginlist.OnCheckItem = self.on_check_item
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With