[pygtk] Drawing over a scrolled image
A.T.Hofkamp
a.t.hofkamp at tue.nl
Tue Sep 15 20:23:05 WST 2009
Fabrice Delente wrote:
> I wasn't specific enough: when I say image, it's in fact a PNG file; I load it in a gtk.Image with load_from_file, and I didn't find any method in gtk.DrawingArea to display a pixbuf (as gtk.Image contains a pixbuf).
Note the first two sentences in the PyGTK DrawingArea reference documentation:
"The gtk.DrawingArea widget is used for creating custom user interface
elements. It's essentially a blank widget containing a gtk.gdk.Window that you
can draw on. .... "
In other words, the method you are looking for is in the gtk.gdk.Drawable
class (base class of gtk.gdk.Window) rather than the gtk.DrawingArea class, eg
code like will display a pixbuf contained in self.pbuf:
def expose(self, area, event):
"""
Render the picture to the screen.
"""
if self.pbuf is None:
return
drawable = self.area.window
gc = drawable.new_gc()
drawable.draw_pixbuf(gc, self.pbuf, 0, 0, 0, 0)
More information about the pygtk
mailing list