[wxPython] Problem saving drawing to a file

It isn't even guaranteed on Windows. Windows tries to do a "save under"
before it draws a menu, and a restore after. This can be foiled if you have
multiple levels of menu.

One alternative is to do ALL your drawing into a memory bitmap, instead of
directly onto the screen, and refresh the screen canvas from the bitmap
instead of vice versa.

Do you have a routine that redraws your canvas? You could have that routine
accept a canvas as a parameter. Then SaveToFile could call that routine with
a canvas from a memory bitmap instead of the screen.

ยทยทยท

On Thu, 24 Oct 2002 07:14:16 -0700, "Echeverria Rabi, Cristien" <cecheverria@transelec.cl> wrote:

I' am sending a python file that shows a problem I have, trying to save a
drawing on a canvas to a file. I' am using the recommended method that
appears on the wiki:

def SaveToFile(self,file_name,file_type):
   context = wxClientDC(self)
   memory = wxMemoryDC()
   x,y = self.pxsize
   x = x + 1
   y = y + 1
   bitmap = wxEmptyBitmap(x,y,-1)
   memory.SelectObject(bitmap)
   memory.Blit(0,0,x,y,context,0,0)
   memory.SelectObject(wxNullBitmap)
   bitmap.SaveFile(file_name,file_type)

In my app I need to select the menu "File->Save Image" to save the current
view. On windows (98 and XP at least) this works very well, but on linux the
area of the drawing covered by the menu is not saved (I got a white area).

--
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.