How to create appmenu in using python3 and PyQt?
I am looking for a way to create appmenu indicator using python3.2 and pyqt4. Please help me.
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.