Drawing a rubberband on a panel without redrawing everthing

73 views
Skip to first unread message

steve

unread,
Sep 22, 2016, 8:45:23 AM9/22/16
to wxPython-users
Hi,
 
I use a wx.PaintDC() to draw shapes on a panel. After drawing the shapes, when I left click and drag mouse, a rubberband (transparent rectangle) is drawn over shapes. While dragging the mouse, for each motion of mouse, an EVT_PAINT is sent and everything (all shapes and rectangle) is redrawn.
 
How do I just draw the rubberband over the existing shapes (I don't want to redraw the shapes), I mean, it would be nice if I can save the existing shapes on some DC object and just draw the rubberband on it. So that the application will draw it faster.
 
Thanks
Best regards

Chris Barker

unread,
Sep 22, 2016, 12:16:11 PM9/22/16
to wxpython-users
On Thu, Sep 22, 2016 at 5:45 AM, steve <osloc...@gmail.com> wrote:
I use a wx.PaintDC() to draw shapes on a panel. After drawing the shapes, when I left click and drag mouse, a rubberband (transparent rectangle) is drawn over shapes. While dragging the mouse, for each motion of mouse, an EVT_PAINT is sent and everything (all shapes and rectangle) is redrawn.
 
How do I just draw the rubberband over the existing shapes (I don't want to redraw the shapes), I mean, it would be nice if I can save the existing shapes on some DC object and just draw the rubberband on it. So that the application will draw it faster.

look into:

wx.lib.floatcanvas

(this may do everything for you already :-) )

Double Buffering:

I have  bunch of demos of various stuff here:


I haven't tested most of them in years, but there's good stuff in there -- and PRs accepted if you find and fix issues!

Drawing with a "XOR" twice:

wxOverlay:
  I've got 4(!) examples of Overlay here:

not sure why -- it's been a while!

This demo:

may be helpful.

-CHB












 
 
Thanks
Best regards

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov

steve

unread,
Sep 22, 2016, 3:41:27 PM9/22/16
to wxPython-users
Sir,
 
Thank you for the info.
 
I'd like to use wx.Overlay() but it doesn't work when Double Buffering is turned on. Thus, I turn it off right before drawing the rubberband, and then turn it on again. Rubberband can be drawn using this workaround. But when I right click on the window to show a pop-up menu and then left click somewhere on the window to remove it, the screen flashes (although I had turned double buffering on). I don't understand. Do you have any ideas why it happens?
 
Best regards
 
Thanks
Best regards
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Chris Barker

unread,
Sep 23, 2016, 3:35:19 PM9/23/16
to wxpython-users
Sorry,

I found wxOverlay to be a bit tricky -- no idea about the flashing :-(

-CHB


To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages