I looked at the example with PyQt for system tray icons and tried to use it in my application.<br>I couldn't get it to work.<br>I couldn't find what the example was doing that I wasn't doing.  I even did the stuff in the same order.<br>
<br>I wound up taking the example and in-lining a bunch of functions then bit by bit removing things until I got a minimalistic system tray icon program.<br>In the end, I wound up with a small sample application where for some reason I need to call QtGui.QGroupBox() with some string or I'll never see the system tray icon.<br>
<br>Below is example code.<br><br>If you remove the line ...<br>self.WHY_DO_I_NEED_TO_DO_THIS = QtGui.QGroupBox("A")<br>... then I don't see any system tray icon.<br><br>Can anyone else verify this?<br>I'm on Linux 64 bit with Python 2.6.5 and PyQt 4.7.2.<br>
Thanks,<br>~Eric<br><br>#!/usr/bin/env python<br><br>from PyQt4 import QtCore, QtGui<br><br>class Window(QtGui.QDialog):<br>    def __init__(self):<br>        super(Window, self).__init__()<br><br>        self.WHY_DO_I_NEED_TO_DO_THIS = QtGui.QGroupBox("A")<br>
        <br>        self.restoreAction = QtGui.QAction("&Restore", self,<br>                triggered=self.showNormal)<br><br>        self.quitAction = QtGui.QAction("&Quit", self,<br>                triggered=QtGui.qApp.quit)<br>
<br>        self.trayIconMenu = QtGui.QMenu(self)<br>        self.trayIconMenu.addAction(self.restoreAction)<br>        self.trayIconMenu.addSeparator()<br>        self.trayIconMenu.addAction(self.quitAction)<br><br>        self.trayIcon = QtGui.QSystemTrayIcon(self)<br>
        self.trayIcon.setContextMenu(self.trayIconMenu)<br><br>        self.trayIcon.setIcon(QtGui.QIcon("./logo.png"))<br><br>        mainLayout = QtGui.QVBoxLayout()<br>        mainLayout.addWidget(QtGui.QPushButton("Help Please"))<br>
        self.setLayout(mainLayout)<br><br>        self.trayIcon.show()<br>        self.setWindowTitle("Systray")<br>        self.resize(400, 300)<br><br>if __name__ == '__main__':<br><br>    import sys<br>
<br>    app = QtGui.QApplication(sys.argv)<br><br>    if not QtGui.QSystemTrayIcon.isSystemTrayAvailable():<br>        QtGui.QMessageBox.critical(None, "Systray",<br>                "I couldn't detect any system tray on this system.")<br>
        sys.exit(1)<br><br>    #QtGui.QApplication.setQuitOnLastWindowClosed(False)<br><br>    window = Window()<br>    window.show()<br>    sys.exit(app.exec_())<br><br>