Facing an error in ultimatelistctrl.py file for python 3.10.10

I work on python 3.10 and installed latest version of wxpython(4.2.1).But I got stuck in one method [HandleColumnCheck(HandleColumnCheck(0, wx.Point(10, 10))] which is inbuild function of ultimatelistctrl.py file.
File “C:\Users\asdf\AppData\Local\Programs\Python\Python310\lib\site-packages\wx\lib\agw\ultimatelistctrl.py”, line 5606, in HandleColumnCheck
rect = wx.Rect(theX + HEADER_OFFSET_X, HEADER_OFFSET_Y + (h - 4 - iy)/2, ix, iy)
TypeError: Rect(): arguments did not match any overloaded call:
overload 1: too many arguments
overload 2: argument 2 has unexpected type ‘float’
overload 3: argument 1 has unexpected type ‘int’
overload 4: argument 1 has unexpected type ‘int’
overload 5: argument 1 has unexpected type ‘int’
overload 6: argument 1 has unexpected type ‘int’
Traceback (most recent call last):

it work if I add // in place of / in line (wx.Rect(theX + HEADER_OFFSET_X, HEADER_OFFSET_Y + (h - 4 - iy)/2, ix, iy)).but as we know that ultimatelistctrl.py is readonly library file of wxpython. and I cann’t do any changes there from user end.

Any suggestion would be great appreciation.

Several issues have been raised in GitHub for problems like this in the UltimateListCtrl.

e.g.

I created Pull Requests to fix it and some other similar bugs in the UltimateListCtrl. The PRs have been merged to the master branch but have not yet been made part of an official release.

In the meantime I have taken a copy of the fixed ultimatelistctrl.py module from the master branch in GitHub and used it to replace the version from 4.2.1 on my own PCs. However, that won’t be a practical solution if you don’t have control of other users’ computers.

No, it’s not readonly. You can edit it as you like :slight_smile: The problem is, as Richard said, that your customers can’t access your computer. However, you can use your own modifications without changing the original code until the fixed version is released.

You have two options. One way is override:

from wx.lib.agw.ultimatelistctrl import UltimateListHeaderWindow
if wx.VERSION <= (4,2,1):
    # This patch affects local (here) and modules that import this module.
    class UltimateListHeaderWindow(UltimateListHeaderWindow):
        def HandleColumnCheck(self, column, pos):
            # Do something new.
            ...
    # or
        def HandleColumnCheck(self, column, pos):
            super().HandleColumnCheck(column, pos)
            # Do something additional to the original code.

Another way is monkey-patch:

from wx.lib.agw.ultimatelistctrl import UltimateListHeaderWindow
if wx.VERSION <= (4,2,1):
    # This patch affects global from when this module is imported.
    def HandleColumnCheck(self, column, pos):
        # Do something special
        ...
    UltimateListHeaderWindow.HandleColumnCheck = HandleColumnCheck
    del HandleColumnCheck

EDIT
Of course, it would be even better if you could report an issue on the bug tracker or submit a PR. :wink: