Ich möchte in mein Programm auch einen SystremTrayIcon einbetten, und hab dafür folgenden Code geschrieben:
Code: Alles auswählen
class SystemTray(QSystemTrayIcon):
def __init__(self, parent = None):
QSystemTrayIcon.__init__(self, parent)
self.parent = parent
self.setIcon(QIcon("..\\Res\\WindowIcon.png"))
tooltip = "xxx"
if self.parent.connected:
tooltip += " [Angemeldet"
if self.parent.secure_mode:
tooltip += " mit Vollzugriff"
tooltip += "]"
self.setToolTip(tooltip)
self.activated.connect(self.handler)
QApplication.instance().aboutToQuit.connect(self.hide)
def handler(self, reason):
if reason == QSystemTrayIcon.DoubleClick: #Icon double clicked
if self.parent.isVisible():
self.parent.hide()
else:
self.parent.show()
Ist das normal oder mach ich was falsch?