TypeError in rcsizer.py with Python 3.10
Operating system: Ubuntu 22.04.1 LTS, 64bit
wxPython version & source: 4.2.0, Ubuntu 23.04 Lunar Lobster package python3-wxgtk4.0 4.2.0+dfsg-1, https://packages.ubuntu.com/lunar/python3-wxgtk4.0 python3-wxgtk4.0_4.2.0+dfsg-1_amd64.deb libwxgtk3.2-0_3.2.1+dfsg-1_amd64.deb libwxbase3.2-0_3.2.1+dfsg-1_amd64.deb python3-wxgtk-media4.0_4.2.0+dfsg-1_amd64.deb libwxgtk-media3.2-0_3.2.1+dfsg-1_amd64.deb
Python version & source: Python 3.10.6, distro package python3 version 3.10.6-1~22.04
Description of the problem:
After upgrading Ubuntu to 22.04 LTS which installed Python 3.10, I got problems in EasyABC (https://github.com/jwdj/EasyABC/issues/63) with error messages TypeError: 'float' object cannot be interpreted as an integer.
I found https://github.com/wxWidgets/Phoenix/issues/2038 and https://github.com/wxWidgets/Phoenix/pull/2039.
In order to get a newer version of wxPython, I installed packages from the upcoming Ubuntu 23.04 Lunar Lobster version, see above.
When I start EasyABC and use the menu item "Settings - ABC settings...", a settings window appears which has a few tabs with all GUI elements overlapping in the top left corner and error messages referring to /usr/lib/python3/dist-packages/wx/lib/rcsizer.py.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/wx/lib/rcsizer.py", line 153, in CalcMin
size = wx.Size( reduce( operator.add, self.colWidths),
TypeError: Size(): 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'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/wx/lib/rcsizer.py", line 163, in RecalcSizes
minWidth, minHeight = self.CalcMin()
File "/usr/lib/python3/dist-packages/wx/lib/rcsizer.py", line 153, in CalcMin
size = wx.Size( reduce( operator.add, self.colWidths),
TypeError: Size(): 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'
and after fixing this by replacing / with // in function _add
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/wx/lib/rcsizer.py", line 198, in RecalcSizes
self.SetItemBounds( item, cpos[c], rpos[r], width, height )
File "/usr/lib/python3/dist-packages/wx/lib/rcsizer.py", line 218, in SetItemBounds
ipt.y = y + (h - isz.height) / 2
TypeError: 'float' object cannot be interpreted as an integer
Replacing all operators / with // in rcsizer.py seems to fix the problem.
The file /usr/lib/python3/dist-packages/wx/lib/rcsizer.py from the distro's package is the same as in https://github.com/wxWidgets/Phoenix/releases/download/wxPython-4.2.0/wxPython-4.2.0.tar.gz
This issue has been mentioned on Discuss wxPython. There might be relevant details there:
https://discuss.wxpython.org/t/facing-an-error-in-wx-library-file-rcsizer-py/36685/2