using backround image for painting

Hi there,
I'm writing a small digitizer application. I examined, several options
for scientific plotting and decided to do everything from scratch.

Idea of the application is simple I want to load a background image and
then digitize some points using a mouse. Every time I click I put a
point on the graph, double click terminates the curve (polyline). Right
click starts a new polyline.

I attached the application and a sample image, just put two files in the
same directory and run "python digitizer.py"

My problem is the following. I want to update the window after I
double-click to terminate the line. However, when I put dc.Clear before
dc.BeginDrawing() in drawAll method, the backround bitmap is not
painted.
For some reason I cannot use dc.DrawBitpam with wxBufferedDC.
When I manually resize the window everything is displayed correctly.
How could I use dc.Clear() to keep the backround image?

Thanks,
~Serge

test1.xpm (768 KB)

digitizer.py (6.88 KB)

···

+++++
This mail has been sent through the MPI for Demographic Research. Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked. If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance.

Serge Boiko wrote:

Hi there,
I'm writing a small digitizer application. I examined, several options
for scientific plotting and decided to do everything from scratch.

Idea of the application is simple I want to load a background image and
then digitize some points using a mouse. Every time I click I put a
point on the graph, double click terminates the curve (polyline). Right
click starts a new polyline.

I attached the application and a sample image, just put two files in the
same directory and run "python digitizer.py"

My problem is the following. I want to update the window after I
double-click to terminate the line. However, when I put dc.Clear before
dc.BeginDrawing() in drawAll method, the backround bitmap is not
painted.

Since your image is to be used for the background, then using it and calling Clear() are mutually exclusive. You can't have a Clear DC and also have a background image at the same time. Probably what you want to do instead of Clear is to just reinitialize your drawing buffer from the image as in your app a "clean drawing surface" *is* the background image, right?

For some reason I cannot use dc.DrawBitpam with wxBufferedDC.

It should work. Can you give more details or an example?

When I manually resize the window everything is displayed correctly.

Because you reinitialize your buffer and then redraw your lines.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!