0

Is there any python library which can get print screenshot on both linux and windows? Any help will be appreciated.

jww
  • 97,681
  • 90
  • 411
  • 885
Jack_of_All_Trades
  • 10,942
  • 18
  • 58
  • 88
  • -1 for what exactly? This baffles me a lot! – Jack_of_All_Trades Mar 21 '12 at 12:48
  • 2
    most likely for not searching google and/or stack overflow. in less than 5 seconds I found this link http://stackoverflow.com/questions/69645/take-a-screenshot-via-a-python-script-linux and that is just one of many – Brian Mar 21 '12 at 12:50

2 Answers2

1

The library Castro can be used for your cause.

Here is a sample code from the documentation

from castro import Castro
c = Castro()
c.start()
# Do something awesome!
c.stop()
Zain Khan
  • 3,753
  • 3
  • 31
  • 54
  • I looked in Castro and it is nice due to its simplicity! thanks. I don't want to use gtk though because I wonder how it will work on windows ( I am scared by its not-native nature to other platform than linux for GUI. I use wxpython for GUI) – Jack_of_All_Trades Mar 21 '12 at 12:57
0

I have googled a bit and saw this on a forumn.

import gtk.gdk

w = gtk.gdk.get_default_root_window()
sz = w.get_size()
print "The size of the window is %d x %d" % sz
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])
if (pb != None):
    pb.save("screenshot.png","png")
    print "Screenshot saved to screenshot.png."
else:
    print "Unable to get the screenshot."

The link to the stackoverflow answer is this

Community
  • 1
  • 1
Zain Khan
  • 3,753
  • 3
  • 31
  • 54