Convert a GTK python script to C

Posted by Jessica on Stack Overflow See other posts from Stack Overflow or by Jessica
Published on 2010-06-15T14:00:15Z Indexed on 2010/06/15 14:02 UTC
Read the original article Hit count: 215

Filed under:
|
|
|

The following script will take a screenshot on a Gnome desktop.

import gtk.gdk

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])
if (pb != None):
    pb.save("screenshot.png", "png")
    print "Screenshot saved to screenshot.png."
else:
    print "Unable to get the screenshot."

Now, I've been trying to convert this to C and use it in one of the apps I am writing but so far i've been unsuccessful. Is there any what to do this in C (on Linux)?

Thanks! Jess.

© Stack Overflow or respective owner

Related posts about python

Related posts about c