Question

Following the answer to this similar stackoverflow question, I tried running this code

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."

However, the resulting image is completely black. My environment is linux mint 16 running in virtualbox on a mac. Was the black image the result of running a linux vm, or is there another reason?

Was it helpful?

Solution

It is the VM that is the issue here I'm pretty sure. At least it was for me.

There are several steps to figure out which part is messing up but most of them are with issues with the display on VM's having issues with the colormaps. so first use:

 gtk.gdk.colormap_get_system() 

to get the colormap to use and replace the colormap in the original code. See if there's a change.

if that is a dead end I would suggest the following:

TURN OF YOUR VIDEO ACCELERATION <====Huge majority of issues fixed here

Roll Back then Update your video/graphics/3d drivers <==This is almost never the problem

Be sure you've got the newest release of pyscreenshot and retry screenshot

Let me know if it still isn't working and I'll send you the full Step-by-step (its quite long and jumps around a lot but it covers just about everything with this issue.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top