How do I get the strings I can insert instead of 'gtk-execute'?


import gobject
import gtk
import appindicator

if __name__ == "__main__":
    ind = appindicator.Indicator("example-simple-client", "gtk-execute",
    ind.set_status (appindicator.STATUS_ACTIVE)

    menu = gtk.Menu()

    for i in range(3):
        buf = "Test-undermenu - %d" % i
        menu_items = gtk.MenuItem(buf)
        menu_items.connect("activate", gtk.main_quit)


My answer below pretty much does it. Still it would be nice to have some python code that puts out all available icons.

  • It would help if you gave a quick python example that we can run to test. (current code does nothing for me) – Ward Muylaert Jun 5 '11 at 18:37
  • Found one here for those wondering. – Ward Muylaert Jun 5 '11 at 18:40
  • Example-Code added. It's basically the code in your link with a small twist – con-f-use Jun 5 '11 at 18:55


import gtk

icon_theme = gtk.icon_theme_get_default()
print icon_theme.list_icons()

The output of which is a tuple of all the icon names:

('input-gaming', 'gnome-aorta', 'stock_bottom', 'config-language', ...) 

See also: gtk.IconTheme.list_icons in the pygtk docs

If you'd like to get your icon as a GtkPixbuf, you can use the load_icon method:

>>> icon_theme.load_icon("gtk-execute", 48, 0)
<gtk.gdk.Pixbuf object at 0xb737443c (GdkPixbuf at 0x907bf38)>

If you want a filename instead, you can use the lookup_icon method:

>>> icon_theme.lookup_icon("gtk-execute", 48, 0).get_filename()

Where 48 is the size of the desired icon (see also: get_icon_sizes).


It follows regular icon naming, which will, as far as I know, start at your theme and then keep falling back till it matches something with the name.

Taking for example the Faenza icon theme I currently use.

In /usr/share/icons/Faenza/index.theme it says (clipped)

[Icon Theme]
Comment=Icon theme project with tilish style, by Tiheum

Notice the Inherits=... line? Those are Faenza's "fallbacks" in case it doesn't have the icon itself.

This is relevant to your question, because you can enter a name for an icon and then the icon will first be searched for in /usr/share/icons/YOURICONTHEME/. In the odd case that it doesn't find it, it will check the fallbacks (in this case /usr/share/icons/gnome/ and /usr/share/icons/hicolor/). You'll find that most (Ubuntu) icon themes inherit from gnome and/or hicolor so if you use the name of an icon in these folders, you can most likely rest assured that every theme will show an icon.


Shameless selfanswer: http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/Stock.html

Edit: No not really. Wrong incomplete answer. For instance "indicator-messages" is not included in that list.

Update: In the folder /usr/share/icons/MYTHEME where MYTHEME denotes the name of the theme in use should be the icons. Will test that now.

Update2: Yes all icons in the aforementioned folder work! And the themes have fallbacks for items not found. The ones in gtk-stock mentioned in the link earlier are from the fallbacks. Would be nice to have some python code that puts out all available icons. One fare good using standard-items of the gtk-stock and the default-theme only, as the others' presence depends on the theme the user employs on runtime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.