aberkowitz aberkowitz - 6 months ago 29
Python Question

Stock Icons not shown on buttons

self.button = gtk.Button(stock=gtk.STOCK_DELETE)


Only Shows:
Delete

Answer

This is a recent change in GTK - the developers wanted icons not to appear on buttons. On Linux, this can be changed by editing the gconf key

/desktop/gnome/interface/buttons_have_icons

On windows, I think (I haven't actually tried this) that you need to set a value in your gtkrc file (for me it's in C:\Program Files\Gtk+\etc\gtkrc) and use a theme that supports icons (I think the default one doesn't).

EDIT in answer to your comment:

Just like this answer, but in Python: http://stackoverflow.com/questions/1734914/in-gtk-how-do-i-make-a-button-with-just-a-stock-icon/1735265#1735265

For python, it's just

image = gtk.Image()
#  (from http://www.pygtk.org/docs/pygtk/gtk-stock-items.html)
image.set_from_stock(gtk.STOCK_**)
button = gtk.Button()
button.set_image(image)
button.set_label("")
Comments