Skip to content

wxPython 4.2.0 ultimatelistctrl issue with floats in Rect() #2240

@finchyfinch

Description

@finchyfinch

Hi There,

WX Version: 4.2.0 msw (phoenix) wxWidgets 3.2.0, Python Version: 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)].

Using ultimatelistctrl in VirtualList setup. Finding it wont accept a ulc.ULC_FORMAT_CENTER for column definitions. Generates the following error;

Traceback (most recent call last):
File "C:\Python310\lib\site-packages\wx\lib\agw\ultimatelistctrl.py", line 5284, in OnPaint
self.DrawTextFormatted(dc, text, wx.Rect(xAligned+EXTRA_WIDTH, int(HEADER_OFFSET_Y), int(cw-EXTRA_WIDTH), int(h-4)))
TypeError: Rect(): arguments did not match any overloaded call:
overload 1: too many arguments
overload 2: argument 1 has unexpected type 'float'
overload 3: argument 1 has unexpected type 'float'
overload 4: argument 1 has unexpected type 'float'
overload 5: argument 1 has unexpected type 'float'
overload 6: argument 1 has unexpected type 'float'

To fix it I need to make the vars within the Rect() in the following line in def OnPaint(self, event): an integer;

From:
self.DrawTextFormatted(dc, text, wx.Rect(xAligned+EXTRA_WIDTH, HEADER_OFFSET_Y, cw-EXTRA_WIDTH, h-4))

To:

self.DrawTextFormatted(dc, text, wx.Rect(int(xAligned+EXTRA_WIDTH), int(HEADER_OFFSET_Y), int(cw-EXTRA_WIDTH), int(h-4)))

Then all is good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions