Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

wx.lib.agw.flatnotebook raises error on changing tab

Open suurjaak opened this issue 3 years ago • 0 comments

Operating system: Ubuntu 22.04 wxPython version & source: 4.0.7 gtk3 (phoenix) wxWidgets 3.0.5 (installed with apt install python3-wxgtk4.0) Python version & source: Python 3.10.4, stock

Description of the problem:

Changing tabs in FlatNotebook can raise an exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/wx/lib/agw/flatnotebook.py", line 5205, in OnPaint
    renderer.DrawTabs(self, dc)
  File "/usr/lib/python3/dist-packages/wx/lib/agw/flatnotebook.py", line 2360, in DrawTabs
    self.DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc._nTabXButtonStatus)
  File "/usr/lib/python3/dist-packages/wx/lib/agw/flatnotebook.py", line 2783, in DrawTab
    x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
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'

The problem is that in https://github.com/wxWidgets/Phoenix/blob/master/wx/lib/agw/flatnotebook.py, a number of calculations use division, but do not explicitly convert the result to an integer. This is probably a holdover from Python2, where integer divided by an integer yielded an integer; in Python3 the result is always a float.

suurjaak avatar Jul 10 '22 16:07 suurjaak