-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wxPython 4.2.0 ultimatelistctrl issue with floats in Rect() #2240
Comments
Python is dynamic but strongly typed language and an int is an int and a float is a float, no magic here, and that rigidity should have been pursued long ago (I'm sure that will peeve a lot of people) |
Just as some further clarification, the issue arises due to this section within ultimatelistctrl.py in the OnPaint function; As I am using ULC_FORMAT_CENTER, its calculation is creating a float in xAligned and then that variable is being used further down in the Rect(). The /2 just needs to be changed to a //2 and all is well. For now as my workaround I am distributing a local copy of the custom control with the necessary patch until a future update / release is made. |
in the docu of Rect it clearly says int and that goes into another language, but the note on // (python 310) warns clearly that the result type may not be int |
I've hit a related issue that does not pertain to formatting, should a new issue be created for this? File "...\venv\lib\site-packages\wx\lib\agw\ultimatelistctrl.py", line 5606, in HandleColumnCheck Simple program to reproduce the issue:
As mentioned by @finchyfinch if you wrap all of the arguments to the wx.Rect method with an int the issue is resolved in python 3.10 or if you add floor division (//) it resolves the issue as well. wx.Rect(int(theX + HEADER_OFFSET_X), int(HEADER_OFFSET_Y + (h - 4 - iy)/2), int(ix), int(iy)) or wx.Rect(theX + HEADER_OFFSET_X, HEADER_OFFSET_Y + (h - 4 - iy)//2, ix, iy) |
This issue has been mentioned on Discuss wxPython. There might be relevant details there: https://discuss.wxpython.org/t/questions-about-plans-for-4-2-1-release/36294/2 |
This issue has been mentioned on Discuss wxPython. There might be relevant details there: |
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.
The text was updated successfully, but these errors were encountered: