[wxPython-users] Drawing a window to a pixmap
Robin Dunn
robin at alldunn.com
Thu Nov 15 16:50:10 PST 2007
Christof wrote:
> Hi,
>
> I need to draw the contents of a window to a pixmap. There does not seem to be a
> Window.Draw() method, since the drawing is initiated by an event.
>
> Is there a way to achieve this?
It depends on what you mean. If you want to do something like a screen
shot can capture everything, including native child widgets, etc. then
there is not an reliable way to do that. You can use a wx.ScreenDC and
blit from that to a wx.Memory but it will only copy the pixels visible
on screen and if another window is overlapping the window in question
then you'll get those pixels instead of your window.
If you just want to be able to draw the same thing to a bitmap that you
are already drawing to the window, then you can do that simply by making
a wx.MemoryDc with a wx.Bitmap selected into it, and then perform the
same drawing code using that dc as you do when painting the window.
(Factoring out the common code into a separate method so it can be
called from both placed works well for this.)
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list