wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
2.33k
stars
516
forks
source link
wx.lib.mixins.rubberband.py does not clear the DC before resizing/moving the rubberband #2627
Open
belono opened 1 month ago
Operating system: Ubuntu Linux 24.04 LTS wxPython version & source: wxPython v.4.2.2 gtk3 (pypi) Python version & source: Python v.3.12.3 (stock)
Description of the problem:
When drawing a rubberband, multiple bounding boxes are drawn that end up filling the entire window.
Code Example (click to expand)
```python app = wx.App() frame = wx.Frame(None, -1, title='RubberBand Test', size=(300,300)) # Add a panel that the rubberband will work on. panel = wx.Panel(frame, -1) panel.SetBackgroundColour(wx.BLUE) # Create the rubberband frame.rubberBand = RubberBand(drawingSurface=panel) frame.rubberBand.reset(aspectRatio=0.5) # Add a button that creates a new rubberband def __newRubberBand(event): frame.rubberBand.reset() button = wx.Button(frame, 100, 'Reset Rubberband') frame.Bind(wx.EVT_BUTTON, __newRubberBand, button) # Layout the frame sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(panel, 1, wx.EXPAND | wx.ALL, 5) sizer.Add(button, 0, wx.ALIGN_CENTER | wx.ALL, 5) frame.SetAutoLayout(1) frame.SetSizer(sizer) frame.Show(1) app.MainLoop() ```This is due to a bug in the __drawAndErase() method that is not clearing the DC before moving or resizing the bounding box but drawing another box.
As the fix is so simple I would be happy to contribute a PR fixing this behavior.