Wx.lib.ogl errors

On python 3.12.4 with wxPython 4.2.2, when I execute the demo for the ogl library and resize any of the rectangle shapes I get the following :

Traceback (most recent call last):
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.2/pyenv-3.12.4/lib/python3.12/site-packages/wx/lib/ogl/canvas.py", line 321, in OnMouseEvent
    self.Draw()
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.2/pyenv-3.12.4/lib/python3.12/site-packages/wx/lib/ogl/canvas.py", line 101, in Draw
    self.GetDiagram().Redraw(dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.2/pyenv-3.12.4/lib/python3.12/site-packages/wx/lib/ogl/diagram.py", line 42, in Redraw
    object.Draw(dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.2/pyenv-3.12.4/lib/python3.12/site-packages/wx/lib/ogl/basic.py", line 1436, in Draw
    self.GetEventHandler().OnDraw(dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.2/pyenv-3.12.4/lib/python3.12/site-packages/wx/lib/ogl/basic.py", line 154, in OnDraw
    self._previousHandler.OnDraw(dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.2/pyenv-3.12.4/lib/python3.12/site-packages/wx/lib/ogl/divided.py", line 181, in OnDraw
    RectangleShape.OnDraw(self, dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.2/pyenv-3.12.4/lib/python3.12/site-packages/wx/lib/ogl/basic.py", line 2774, in OnDraw
    dc.DrawRectangle(int(x1), int(y1), self._width, self._height)
TypeError: DC.DrawRectangle(): arguments did not match any overloaded call:
  overload 1: argument 3 has unexpected type 'float'
  overload 2: argument 1 has unexpected type 'int'
  overload 3: argument 1 has unexpected type 'int'

Looks like some computations are using just ‘/’ instead of ‘//’ to coerce everything to an integer

Please try wxPython 4.2.3. I believe those have been fixed.

1 Like

Thanks !!!, I missed that announcement

Although problem still exists in dc.DrawEllipse

Traceback (most recent call last):
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.3/pyenv-3.12.9/lib/python3.12/site-packages/wx/lib/ogl/canvas.py", line 321, in OnMouseEvent
    self.Draw()
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.3/pyenv-3.12.9/lib/python3.12/site-packages/wx/lib/ogl/canvas.py", line 101, in Draw
    self.GetDiagram().Redraw(dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.3/pyenv-3.12.9/lib/python3.12/site-packages/wx/lib/ogl/diagram.py", line 42, in Redraw
    object.Draw(dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.3/pyenv-3.12.9/lib/python3.12/site-packages/wx/lib/ogl/basic.py", line 1436, in Draw
    self.GetEventHandler().OnDraw(dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.3/pyenv-3.12.9/lib/python3.12/site-packages/wx/lib/ogl/basic.py", line 154, in OnDraw
    self._previousHandler.OnDraw(dc)
  File "/Users/humberto.a.sanchez.ii/Documents/Developer/wxPython-demo-4.2.3/pyenv-3.12.9/lib/python3.12/site-packages/wx/lib/ogl/basic.py", line 3447, in OnDraw
    dc.DrawEllipse(int(self._xpos - self.GetWidth() / 2.0), int(self._ypos - self.GetHeight() / 2.0), self.GetWidth(), self.GetHeight())
TypeError: DC.DrawEllipse(): arguments did not match any overloaded call:
  overload 1: argument 3 has unexpected type 'float'
  overload 2: argument 1 has unexpected type 'int'
  overload 3: argument 1 has unexpected type 'int'

well, try

dc.DrawEllipse(int(self._xpos - self.GetWidth() / 2.0), int(self._ypos - self.GetHeight() / 2.0), int(self.GetWidth()), int(self.GetHeight()))

for line 3447 in Python313\Lib\site-packages\wx\lib\ogl\basic.py :rofl:

i know how to fix the code, but it is a library I do not control

I’d suggest opening a PR with the fix(es), I’m sure @swt2c will be happy to apply it.

Unfortunately, I have no idea how to build wxPython from scratch to validate any of my fixes. I have tried looking at the instructions, but they seem dated

In the meantime in PseudoMetaFile.SetBackgroundColour() this code

 def SetBackgroundColour(self, colour):
        op = OpSetGDI(DRAWOP_SET_BK_COLOUR, self, 0)
        op._r, op._g, op._b = colour.Red(), colour.Green(), colour.Blue()

        self._ops.append(op)

errors as follows:

    self.SetDrawnBackgroundColour(UmlUtils.backGroundBrush())
  File "/Users/humberto.a.sanchez.ii/PycharmProjects/umlshapes/pyenv-3.12.9/lib/python3.12/site-packages/wx/lib/ogl/drawn.py", line 850, in SetDrawnBackgroundColour
    self._metafiles[self._currentAngle].SetBackgroundColour(colour)
  File "/Users/humberto.a.sanchez.ii/PycharmProjects/umlshapes/pyenv-3.12.9/lib/python3.12/site-packages/wx/lib/ogl/drawn.py", line 614, in SetBackgroundColour
    op._r, op._g, op._b = colour.Red(), colour.Green(), colour.Blue()
                          ^^^^^^^^^^
AttributeError: 'Brush' object has no attribute 'Red'. Did you mean: 'Ref'?

luckily (for you) this is not the last hickup in this piece of art :rofl:

Like I said, if I could find a decent set of instructions to build this thing on my MacBook Pro, I would gladly contribute a PR

It looks like the problems you’re seeing are all in pure Python files, so you can just modify them in place in your virtualenv to test your changes (there is no need to build anything).

If you really want to build wxPython though, the instructions are in the repository in the README.

I tried to open a pull request to submit the python file changes. however the button is greyed out. Do I need to be part of a certain list

When I go to the Phoenix repository to the pull requests, the button is greyed out.

From gh

GraphQL: Your token has not been granted the required scopes to execute this query. The 'filename' field requires one of the following scopes: ['repo'], but your token has only been granted the: ['project', 'public_repo', 'read:user', 'repo:status'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens., Your token has not been granted the required scopes to execute this query. The 'body' field requires one of the following scopes: ['repo'], but your token has only been granted the: ['project', 'public_repo', 'read:user', 'repo:status'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.