saving content of the panel into PNG file

You aren't using sizers here. Because of that, none of the sizes get adjusted. The frame does not adjust itself to fit the panel, nor vice versa.

Assume the render size is 1024x768. You set the frame (the outer window) to (2,2) larger than that, or 1026x770. You set the panel at 1024x768. Now, because of the decorations (border, title bar, etc), the client area of the frame is actually 8x34 smaller than 1026x770, or 1018x736. The panel is still 1024x768, and always will be. It's just that the bottom and right sections of the panel are not visible. The panel doesn't have decorations, so it's client size and window size are the same. It's the FRAME that has the decorations. If you had dumped the frame's ClientSize, this would have been clear.

So, if you really want the outer window to be 1026x770, you can use frame.ClientSize to find out how much of the panel is really visible. If you really want the visible panel to be 1024x768, then you need to increase the size of the FRAME to make up the difference. A sizer would do that for you, or you can do this before you create the panel:

    wsz = frame.Size
    csz = frame.ClientSize
    frame.Size = (w + wsx[0] - csx[0], h + wsx[1] - csx[1] )

By the way, it was not terribly helpful of you to point at the source code download without giving at least a hint on on how to USE the application, or how to duplicate the problem. When you are asking for free help, YOU need to be as specific as possible.

ยทยทยท

On Tue, 26 Feb 2008 14:38:59 +0100, "Jacek Poplawski" <jacekpoplawski@gmail.com> wrote:

After two weeks fighting with so simple issue I can only say that something must be really broken.

Yes, maybe I am doing something wrong with wxPython API but I really don't understand why sizes don't match.

        frame = wx.Frame(None, size=(ww,hh), title="Magic Garden Render")
        frame.Show(True)
        panel = magic_panel.MagicGardenPanel(frame, (ww,hh))
(...)
        dc = wx.ClientDC(panel)
        w,h = panel.GetClientSize()
        #w,h = dc.GetSize()
        memory = wx.MemoryDC( )
        bitmap = wx.EmptyBitmap( w, h )
        memory.SelectObject( bitmap )
        memory.Blit( 0, 0, w, h, dc, 0, 0)
        memory.SelectObject( wx.NullBitmap)
        filename="renders/render_"+str(self.__render_counter)+".png";
        bitmap.SaveFile( filename, wx.BITMAP_TYPE_PNG)

I also tried using GetRect() from panel, but got exactly same result.
Bitmap has not just panel but also bottom part of desktop. It just takes too much.
For some reason GetSize()/GetClientSize()/GetRect() returns invalid value or Blit doesn't work correctly.

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