Skip to content
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

wx.lib.mixins.rubberband.py does not clear the DC before resizing/moving the rubberband #2627

Open
belono opened this issue Oct 20, 2024 · 0 comments

Comments

@belono
Copy link

belono commented Oct 20, 2024

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)
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant