Ubuntu app indicators when using PyGObject

PyGObject and the Python appindicator module don’t agree with each other. As soon as I import “appindicator”, all objects from the gi.repository.Gtk namespaces seem to reset to what might be PyGTK, not sure. However, with gir1.2-appindicator-0.1 (on Natty) installed , you can do:

from gi.repository import AppIndicator

ind = AppIndicator.Indicator.new(

self.menu = Gtk.Menu()
item = Gtk.MenuItem()
item.set_label("Menu Item")


Note that there is a gir1.2-appindicator3-0.1 package in Natty, which provides a AppIndicator3 object, which seems to be the GTK3 version, and pulls a bunch of GTK dependencies. After installing it on Natty, I was seemingly unable to work with GTK2 in PyGObject, so be careful (uninstalling the GTK3 packages fixed it). Jockey (the “Additional Drivers” tool) is using AppIndicator3, and from looking at the source, AppIndicator3 works without attaching a menu to it. Apparently Canonical still gets some things right.

Update 2012-04-10: In order to make my app work with both Gtk3 (Oneiric) and Gtk2 (Natty), I am now using this code:

   from gi.repository import AppIndicator3 as AppIndicator
   from gi.repository import AppIndicator

1 thought on “Ubuntu app indicators when using PyGObject

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s