def drawWindow(win, e):
    width, height = win.get_size()
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
screenshot = pixbuf.get_from_drawable(win.window, win.get_colormap(), 0, 0,
    0, 0, width, height)
screenshot.save('screenshot.png', 'png')
global handlerId
win.disconnect(handlerId)
if __name__ == '__main__':
    main()
gtk.main()
Creating a screenshot of a gtk.Window