Nigel Tao <[EMAIL PROTECTED]> writes:

> I have a GtkDialog for which I want to:
> dialog.set_icon(gtk.image_new_from_stock(gtk.STOCK_FIND,
> gtk.ICON_SIZE_MENU).get_pixbuf())
> 
> but I get the following error:
> ValueError: image should be a GdkPixbuf or empty
> 
> Indeed, the PyGTK docs ( http://www.pygtk.org/pygtk2reference/class-
> gtkimage.html#method-gtkimage--get-pixbuf ) say that exactly that will
> happen - get_storage_type() on the image returns GTK_IMAGE_STOCK, which
> is not GTK_IMAGE_PIXBUF.
> 
> Fair enough.  So how do I instead set a window's icon to a stock image?
> Alternatively, how do I get a pixbuf from a stock image?
> 

As you note, since you want a pixbuf rather than a gtkImage widget a
more direct approach would be nicer.  You can get a stock icon pixbuf
using the gtkWidget render_icon() method.  (Unfortunately ethods like
these that are far up the inheritance hierarchy can be hard to find.)

    pixbuf = dialog.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU)
    dialog.set_icon(pixbuf)
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to