Bjorn Harpe Bjorn Harpe - 7 months ago 61
Python Question

Saving wxPython scrolledcanvas contents to image

I've been trying this for a bit and haven't found a solution that works for me

I have a

that I'm trying to save to an image, however when i use the answers I've found they all save only the visible portion of the canvas, and not the full canvas. Is there any way to save the entirety of the scrolled canvas to a file?



Refactor your code such that what you are drawing in your EVT_PAINT handler can be called passing it the wx.DC to be drawn upon, and then call that from your paint handler with the wx.PaintDC or whatever you are currently using. When you want to save it to an image call the same code passing a wx.MemoryDC with a wx.Bitmap selected into it. When it's done the bitmap will have the same contents as the window, and you can then save it to a file or whatever you need to do with it.