Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am looking for a way to create appmenu indicator using python3.2 and pyqt4. Please help me.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Short: Ubuntu 11.10 ships a patched QT that will make a QSystemTrayIcon create an indicator if possible. In older Ubuntu versions you will need a patched version of Qt, and this will make your program a pain to distribute.

Long: There is a patch provided by Canonical to use indicators in Qt, but it's not yet integrated in the official Qt release and it's not likely to happen before Qt 5. Sources: The author blog, an post in the Qt forum from a Nokia/Trolltech developer.

Ubuntu 11.10 ships with this patch enabled, so a code like this will create an indicator if used in 11.10

import sys
from PyQt4 import QtGui

app = QtGui.QApplication([])
icon = QtGui.QSystemTrayIcon(QtGui.QIcon("test.png"), app)
menu = QtGui.QMenu()
menu.addAction("Quit", QtGui.qApp.quit)
icon.setContextMenu(menu)
icon.show()
app.exec_()

You will need a suitable icon in test.png.

Note that KDE (not plain QT) apps already support indicator by using kdelibs.

There is also the libindicate-qt project, but I can't find python biddings for it nor any documentation.

share|improve this answer
    
Be sure to install the sni-qt package for this to work. Note that libindicate-qt is not about appindicators: it is mainly used by applications to integrate into the messaging menu (example users include Quassel, Konversation, Kopete and KMail) –  agateau Nov 2 '11 at 15:54

Your Answer

 
discard

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.