Right now I have a few manual test cases where the dialogs of my application can be run independently from the logic for the purpose of just testing the GUI and i18n stuff. Since I have the dialogs isolated, I was wondering if there would be a way to programatically create screenshots of these dialogues.
If this is possible I could create a script going through all the dialogs and generate png captures of them, which I could easily embed in end user documentation without going around with a screen capture tool. Plus I could regenerate these whenever the code changes autoupdating the documentation.
Is this possible at all?
···
--
Grzegorz Adam Hankiewicz, Jefe de producto de TeraVial
Rastertech España S.A. Tel: +34 918 467 390, ext 18.
http://www.rastertech.es/ ghankiewicz@rastertech.es
1: Create a wxClientDC for the window you wish to capture
2: Create a bitmap of the same size
3: Create a wx.MemoryDC and select the bitmap into it
4: Blit() the ClientDC into the MemoryDC
5: Unselect the wxBitmap from the MemoryDC
6: Create a wx.Image from the bitmap, and save it into PNG format.
There's some code for this on wxPython wiki, I believe.
···
On 1/12/07, Grzegorz Adam Hankiewicz <ghankiewicz@rastertech.es> wrote:
Right now I have a few manual test cases where the dialogs of my
application can be run independently from the logic for the purpose of
just testing the GUI and i18n stuff. Since I have the dialogs isolated,
I was wondering if there would be a way to programatically create
screenshots of these dialogues.
If this is possible I could create a script going through all the
dialogs and generate png captures of them, which I could easily embed in
end user documentation without going around with a screen capture tool.
Plus I could regenerate these whenever the code changes autoupdating the
documentation.
Is this possible at all?
This sounded like a nifty idea so I decided to try out out for myself. I couldn't find any code on the wiki, but with Chris' info and help() I was able to get it to work fine.
Here's some code:
windowdc = wx.WindowDC(window)
size = window.GetSize()
image = wx.EmptyBitmap(*size)
memorydc = wx.MemoryDC()
memorydc.SelectObject(image)
memorydc.Blit(0,0,size[0],size[1],windowdc,0,0)
image.SaveFile("screenshot.png",wx.BITMAP_TYPE_PNG)
"window" would be your main wxFrame if you wanted a screenshot of the whole app. If you use a regular ClientDC rather than a WindowDC in windows, you won't get the title bar at the top.
···
-----Original Message-----
From: Chris Mellon [mailto:arkanes@gmail.com]
Sent: Friday, January 12, 2007 9:39 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Programatically create screenshots of the
GUI
1: Create a wxClientDC for the window you wish to capture
2: Create a bitmap of the same size
3: Create a wx.MemoryDC and select the bitmap into it
4: Blit() the ClientDC into the MemoryDC
5: Unselect the wxBitmap from the MemoryDC
6: Create a wx.Image from the bitmap, and save it into PNG format.