xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #405: qttray.py

File qttray.py, 518 bytes (added by Antoine Martin, 8 years ago)

simple qt tray example

Line 
1import sys
2from PyQt4 import QtGui
3
4class SystemTrayIcon(QtGui.QSystemTrayIcon):
5
6    def __init__(self, icon, parent=None):
7        QtGui.QSystemTrayIcon.__init__(self, icon, parent)
8        menu = QtGui.QMenu(parent)
9        exitAction = menu.addAction("Exit")
10        self.setContextMenu(menu)
11
12def main():
13    app = QtGui.QApplication(sys.argv)
14
15    w = QtGui.QWidget()
16    trayIcon = SystemTrayIcon(QtGui.QIcon("icon.png"), w)
17
18    trayIcon.show()
19    sys.exit(app.exec_())
20
21if __name__ == '__main__':
22    main()