Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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.

share|improve this question
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

3 Answers 3

up vote 12 down vote accepted


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).

share|improve this answer

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.

share|improve this answer

Shameless selfanswer:

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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