[pygtk] icon from theme (Linux)

J j90314 at googlemail.com
Wed Sep 15 05:55:31 WST 2010


When I have an image 'elephant.png' in /usr/share/icons/hicolor/64x64/apps,
"gtk.IconTheme().get_search_path()" gives

('/home/j/.icons', '/home/j/.local/share/icons', '/usr/share/gnome/icons',
'/usr/local/share/icons', '/usr/share/icons', '/usr/share/gnome/pixmaps',
'/usr/local/share/pixmaps', '/usr/share/pixmaps')

but "gtk.IconTheme().has_icon('elephant')" returns False.  However, if I place
elephant.png in /usr/share/pixmaps, it returns True, and for a gtk.Window "w",
setting the icon using "w.set_icon(gtk.IconTheme().load_icon('elephant', 64,
0))" works.

gtk.Window.set_icon_name seems like it should be a shortcut for the above, but
"w.set_icon_name('elephant')" doesn't work with the image in either of the
mentioned paths.  What's more, gtk.StatusIcon.set_icon_from_name _does_ work,
but again only if the image is in /usr/share/pixmaps.

Am I misunderstanding how this works, or is something going wrong?  This is
using the python-gtk2 package from the Ubuntu repositories, listed as version
2.17.0-0ubuntu2.


More information about the pygtk mailing list