Skip to content

Instantly share code, notes, and snippets.

@adambard
Created September 3, 2011 00:53
Show Gist options
  • Save adambard/1190312 to your computer and use it in GitHub Desktop.
Save adambard/1190312 to your computer and use it in GitHub Desktop.
DDBot: Take Screenshot
def take_screenshot():
"""
Use GTK to get a screengrab of the current screen.
Returns an (x, y, 3) full-color pixel array
"""
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
return pb.get_pixels_array()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment