wxPython4.1.0, demo CheckListCtrl error

In previous version 4.0.6, the CheckListCtrl works fine, but since I use 4.1.0 : the same code doesn’t work anymore.

So, I tried the demo code for CheckListCtrl, and it raises this error :

An error has occurred while trying to run the demo
...
ListCtrl.CheckItem(): not enough arguments

Do you have the same issue ? Do you have this same behavior ? Is it a already known one ?

Thank you

Here is a code example, you can verify that you can’t get the check widget ‘checked’…achecklistTest.py (2.6 KB)

(with 4.1.0 version)

The issue is that the wx.ListCtrl class has gained a CheckItem method which has a slightly different API. So when you call CheckItem it’s finding the one in wx.ListCtrl first in the MRU instead of the one in the mixin class.

https://docs.wxpython.org/wx.ListCtrl.html#wx.ListCtrl.CheckItem

I thought I had implemented a fix or workaround for this, but I can’t seem to find it now. Perhaps it was on a branch that didn’t get merged. Anyway, since the wx.ListCtrl is now able to provide checkboxes then one option is to drop using the mixin class, and switch to using the built-in checkbox support instead. You just need to call EnableCheckBoxes first.

Sorry to bother you again with that code, but when I inserted EnableCheckBoxes in the example I attached in my previous post :
now appear 2 check boxes.
Can you fix my code in the previous example and join it to your answer, in order I can understand how it have to be used ?
I’m not in a hurry, so I can wait for your next version of wxPython, and mainly to have a demo example I could rely on .
Thank you again for your great work :slight_smile:

It’s because now you are using checkbox functionality from the ListCtrl class, and also from the CheckListCtrlMixin class. You only need one of them, so remove CheckListCtrlMixin from the list of base classes of your derived class.

Please note that the new built-in checkbox functionality will not be fully compatible with the API of the CheckLIstBoxCtrl, so you’ll probably need to make some other changes (methods called, events, etc.) but you should be able to find the details in the documentation.

I changed from widget CheckListCtrlMixin to ListCtrl and the option EnableCheckBoxes, then I made some adjustments :
all is fine now, the behaviour of my software comes again as before in 4.0.6.

Thanks Robin :slight_smile:

Problem solved !