drawing shapes

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
yuhobebbho
In need of some credit
In need of some credit
Posts: 2
Joined: Thu Jan 03, 2013 2:29 pm

drawing shapes

Post by yuhobebbho » Thu Jan 03, 2013 3:29 pm

hi everyone,
I'm a newbie to wxpython programming, I know how to draw shapes(lines, rectangles etc) on the drawingarea widget at runtime, but cannot control each shapes after it has been drawn. eg. draw a rectangle on the screen then afterward, select it with the mouse and adjust its size or move it to another location within the exposed area. (like how one can draw shapes and edit them in archicad). and whenever i draw a new one, the prevous disappears.

thanks in advance.

User avatar
doublemax
Moderator
Moderator
Posts: 13736
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: drawing shapes

Post by doublemax » Thu Jan 03, 2013 9:18 pm

This is something you have to do implement in your code.

Basically, you keep a list of shapes with their coordinates on the canvas.

If the user starts a dragging operation, you iterate through the list to find the shape under the mouse cursor.

While the user drags, you update the position of that shape in your internal list accordingly and redraw the whole scene.
Use the source, Luke!

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: drawing shapes

Post by Auria » Sun Jan 06, 2013 3:46 pm

wxAtrt2D and wxShapeView may also help ( http://wiki.wxwidgets.org/WxFAQ#How_can ... d_nodes.3F ) though I am not sure if they can be used from wxPython. I suggest you go through the wxPython demo, I seem to remember that it contained some pre-made components from which you could maybe start
"Keyboard not detected. Press F1 to continue"
-- Windows

yuhobebbho
In need of some credit
In need of some credit
Posts: 2
Joined: Thu Jan 03, 2013 2:29 pm

Re: drawing shapes

Post by yuhobebbho » Fri Jan 11, 2013 8:22 am

doublemax wrote:This is something you have to do implement in your code.

Basically, you keep a list of shapes with their coordinates on the canvas.

If the user starts a dragging operation, you iterate through the list to find the shape under the mouse cursor.

While the user drags, you update the position of that shape in your internal list accordingly and redraw the whole scene.
thanks, am on it now. will get back to you

Post Reply