Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What event is emitted by wxPython when an item in a CheckListCtrlMixin is checked?

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)
like image 206
Willi Ballenthin Avatar asked Sep 18 '25 20:09

Willi Ballenthin


1 Answers

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
like image 157
Anonymous Coward Avatar answered Sep 20 '25 12:09

Anonymous Coward