In these cases it is useful to read the documentation from Gtk itself, instead of the PyGtk, as they are more complete.
In this case the relevant functions are gtk_image_set_from_pixmap()
and gtk_image_get_pixbuf()
:
Gets the GdkPixbuf being displayed by the GtkImage. The storage type of the image must be GTK_IMAGE_EMPTY or GTK_IMAGE_PIXBUF.
The problem is that the GtkImage
widget can hold both a GdkPixbuf
, a GdkPixmap
, a GdkImage
... but it cannot convert between them, that is, you can only recover what you stored.
You are storing a pixmap and trying to get a pixbuf, and that will not work. Now, what is the solution? That depends on what you are trying to do exactly. Probably it is enough if you convert it to a pixbuf with gtk.pixbuf.get_from_drawable():
w,h = disp.pixmap.get_size()
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, w, h)
pb.get_from_drawable(disp.pixmap, disp.pixmap.get_colormap(),
0, 0, 0, 0, width, height)
pb.save('path.png')