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:

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: