Drawing Rectangles

Sorry, I lost track of the original thread for this.

After posting, I remembered that I had written a demo for FloatCanvas

http://trac.paulmcnett.com/floatcanvas

that did exactly what the OP wanted. It turns out that it was broken, so I've fixed it and am telling you about it now.

It requires the latest from SVN (the fix required a fix to the lib):

http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/FloatCanvas/

The demo is in the Demos directory, called "DrawRect.py"

If all the OP wants is what he stated, then there may be no need for this, but if he ultimately want complex drawing, plus maybe zooming and panning, etc, then FloatCanvas could be very helpful.

-Chris

···

--
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.Barker@noaa.gov

Hi!

I guess it was me. :slight_smile:
I've asked for drawing rectangles temporarily onto some sort of
"canvas". I played around with Robin's "Overlay demo" and it worked
fine in the first place - until I tried to translate my test to a
scrolled window. When I started this, the coordinates of my rectangles
went nuts and the drawing/redrawing was full of flickers....

Thank you for this example. I guess I stumbled upon your original
code, when I did research for a "canvas" some weeks ago. Unfortunately
I must admit, that I don't even understand a tenth of all this. Even
the demo seems to have more features than I actually need. On the
other hand I have a hard time loading an image and draw it onto any
object's DC.

I thought there has to be an "easy" solution for what I want to
achieve, but it seems like I have to start from scratch.

I thank you, Chris, for searching for the topic, fixing your demo and
posting it here.

···

On 9 Nov., 18:38, "Chris.Barker" <Chris.Bar...@noaa.gov> wrote:

Sorry, I lost track of the original thread for this.

After posting, I remembered that I had written a demo for FloatCanvas

http://trac.paulmcnett.com/floatcanvas

that did exactly what the OP wanted. It turns out that it was broken, so
I've fixed it and am telling you about it now.

It requires the latest from SVN (the fix required a fix to the lib):

http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/FloatCanvas/

The demo is in the Demos directory, called "DrawRect.py"

If all the OP wants is what he stated, then there may be no need for
this, but if he ultimately want complex drawing, plus maybe zooming and
panning, etc, then FloatCanvas could be very helpful.

-Chris

--
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.Bar...@noaa.gov

I've asked for drawing rectangles temporarily onto some sort of
"canvas". I played around with Robin's "Overlay demo" and it worked
fine in the first place - until I tried to translate my test to a
scrolled window. When I started this, the coordinates of my rectangles
went nuts and the drawing/redrawing was full of flickers....

Thank you for this example. I guess I stumbled upon your original
code, when I did research for a "canvas" some weeks ago. Unfortunately
I must admit, that I don't even understand a tenth of all this. Even
the demo seems to have more features than I actually need.

I'm sure it does, but you don't need to use all the features!

I thought there has to be an "easy" solution for what I want to
achieve, but it seems like I have to start from scratch.

well, what do you ultimately need? If it's just the drawing of rectangles, then you'll do fine to start from scratch.

On the other hand, if you want other shapes, the ability to zoom and pan, the ability to bind events to clicking on the objects, etc, then taking a bit of time to learn FloatCanvas will save you a lot of code writing.

-Chris

···

On 11/14/11 1:40 AM, PeterK wrote:

I thank you, Chris, for searching for the topic, fixing your demo and
posting it here.

--
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.Barker@noaa.gov

I think I only need the mentioned features:

  • load an image
  • draw rectangles on it
  • save the rects in a list during runtime
  • delete certain rects
  • pickle the list with information which image was used.
    or
  • load pickled file
  • load corresponding image
  • fill list with rects
  • draw the rects
  • edit the rects.

My first thought was to use a list control to manage the list of rects. I know, it’s not very user friendly.

So your question what I ‘utlitmately’ need is a good one. For usability I’d say: yes, let me pan and zoom, let me select the rects just by clicking. But I’m afraid this is a little beyond my knowledge atm and I don’t want to just copy & paste, I want to understand what happens.

To make a long story short: I’d like to load images of comic strips, draw rects around the ‘panels’ and make some kind of slideshow, where a ‘player’ loads the pickled file later on and moves the “camera” from one panel to the next.
It should be a little like the comic apps availiable for iDevices and Androids.