A snap of the screen in wxPython

Saturday, August 26, 2006

This python program takes a snapshot of the screen.
WxPython is required.

import wx
filename = "snap.png"
app = wx.PySimpleApp()
p = wx.GetDisplaySize()
bitmap = wx.EmptyBitmap( p.x, p.y)
dc = wx.ScreenDC()
memdc = wx.MemoryDC()
memdc.SelectObject(bitmap)
memdc.Blit(0,0, p.x, p.y, dc, 0,0)
memdc.SelectObject(wx.NullBitmap)
bitmap.SaveFile(filename, wx.BITMAP_TYPE_PNG )
wx.MessageBox("A %s X %s snap of the screen\nis at %s" % (p.x, p.y, filename ), "Hey!")

0 comments: to “ A snap of the screen in wxPython so far...