Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing an application that needs to use an indicator. I've done this in the past using PyGTK and GTK2, using as reference this document:

However, that only works with PyGTK and GTK2. Things have changed since then, and I need to find some good documentation, a tutorial or a good example to learn how it works.

Also, one thing that the previously mentioned document doesn't describe at all, is how to add sub-menus to an indicator. I hope someone can shed some light on this, as well as how to integrate with category indicators if that's done using the same tool.


share|improve this question
up vote 17 down vote accepted

This is my trial code for gtk3 and appindicator which creates a indicator for GPaste.


from gi.repository import AppIndicator3 as AppIndicator

in order to use appindicator for gtk3 applications which is provided by package gir1.2-appindicator3.

Here is the AppIndicator3 documentation.

pygtk will be deprecated for Gtk3 and you have to go through GObject-Introspection route for developing Gtk3 applications in python. You can refer to PyGObject documentation. Instead of

import pygtk, gtk, gdk, gobject, pango  

etc you should do

from gi.repository import Gtk, Gdk, Pango, GObject  

For studying a working code, you could view Kazam which has moved to gtk3 from gtk2 and uses appindicator3.

There is a package gir1.2-appindicator as well which seems to be same as using python-appindicator as they both provide usage for gtk2 appplication which is:

from gi.repository import AppIndicator


import appindicator

Some information in this blog post as well.

share|improve this answer
I went with AppIndicator3. But does this mean that AppIndicator 1 is a direct port of python-appindicator whereas AI3 is a new version that isn't backported? – Jo-Erlend Schinstad Feb 27 '12 at 21:32
It seems that way. I loaded appindicator 0.1 from python shell and then tried loading appindicator3 which gave me this error RepositoryError: Requiring namespace 'Gtk' version '3.0', but '2.0' is already loaded. So it seems appindicator 0.1 works with gtk2 i.e. pygtk and appindicator3 and above if any works with gtk3 – sagarchalise Feb 28 '12 at 4:08
Ah, I get it. It's not version 3 of AI. It's AI for GTK3 :) – Jo-Erlend Schinstad Feb 28 '12 at 8:50
I've also noticed this blog entry discussing the use of AppIndicator3, which you might find interesting. – David Planella Feb 28 '12 at 10:17
Just a note, most of these links are dead. – RobotHumans Jan 23 '14 at 21:44

Here's a stupid simple scaffold application that has a config window, a main window, and an app indicator.

#!/usr/bin/env python3.3

from gi.repository import Gtk
from gi.repository import AppIndicator3 as appindicator

class MyIndicator:
  def __init__(self, root): = root
    self.ind =
    self.ind.set_status (appindicator.IndicatorStatus.ACTIVE) = Gtk.Menu()
    item = Gtk.MenuItem()
    item.set_label("Main Window")
    item.connect("activate",, '')

    item = Gtk.MenuItem()
    item.connect("activate",, '')

    item = Gtk.MenuItem()
    item.connect("activate", self.cb_exit, '')

  def cb_exit(self, w, data):

class MyConfigWin(Gtk.Window):
  def __init__(self, root):
    super().__init__() = root
    self.set_title( + ' Config Window')

  def cb_show(self, w, data):

class MyMainWin(Gtk.Window):
  def __init__(self, root):
    super().__init__() = root

  def cb_show(self, w, data):

class MyApp(Gtk.Application):
  def __init__(self, app_name):
    super().__init__() = app_name
    self.main_win = MyMainWin(self)
    self.conf_win = MyConfigWin(self)
    self.indicator = MyIndicator(self)

  def run(self):

if __name__ == '__main__':
  app = MyApp('Scaffold')
share|improve this answer

Just in case someone might find it useful, I made a minimal app indicator with Python, GIR and GTK3. It reads CPU speeds from /proc/cpuinfo every few seconds and displays them.

See here:

share|improve this answer
Thank you for your code example! – vrcmr Apr 1 '13 at 19:33

Here is an example of reading cpu temperature. copy an icon named temp-icon.png/svg in the script directory

from gi.repository import Gtk, GLib
from gi.repository import AppIndicator3 as appindicator
import os

def cb_exit(w, data):

def cb_readcputemp(ind_app):
# get CPU temp
   fileh = open(
  ind_app.set_label(, '')
  return 1

ind_app = appindicator.Indicator.new_with_path (
ind_app.set_status (appindicator.IndicatorStatus.ACTIVE)

# create a menu
menu = Gtk.Menu()
menu_items = Gtk.MenuItem("Exit")
menu_items.connect("activate", cb_exit, '')
GLib.timeout_add(500, cb_readcputemp, ind_app)
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.