Image capture

Kartic kartic.krishnamurthy at gmail.com
Wed Jan 5 11:48:02 EST 2005


Hi Catalin,

Here are the modifications to your code. I am emailing you the complete
file back to your email address. Please note that you need PIL (Python
Imaging Library) to grab the window. I included a step to save the
image, but you can do whatever you want with it.

Thanks,
--Kartic

-------------- Unified Diff ---------------

--- Catalin.txt Wed Jan 05 11:43:38 2005
+++ frmDesign.py        Wed Jan 05 11:43:17 2005
@@ -1,7 +1,7 @@
from wxPython.wx import *
from wxPython.grid import *
from win32api import SendMessage
-import win32ui
+import win32ui, win32gui, ImageGrab

WM_PAINT = 0xf
WM_PRINT = 0x317
@@ -47,6 +47,10 @@
dc = wxMemoryDC()
dc.SelectObject(bmp)
dc.Clear()
+       win_sz = win32gui.GetWindowRect(self.grd.GetHandle())
+       print win_sz
+       im = ImageGrab.grab((win_sz[0],win_sz[1],win_sz[2],win_sz[3]))
+       im.save('C:/TEMP/grid.jpg')
SendMessage(self.grd.GetHandle(), WM_PAINT, dc.GetHDC(), 0)
SendMessage(self.grd.GetHandle(), WM_PRINT, dc.GetHDC(),
PRF_CHILDREN|PRF_CLIENT|PRF_OWNED)




More information about the Python-list mailing list