[PyQt] Problem with QSystemTrayIcon.showMessage

Zdenko Podobny zdenop at gmail.com
Mon Apr 1 17:39:03 BST 2019


Hello,

I try to create systemtray application and I have some issue
with showMessage function:
When message is shown (e.g. when calling settings or exit function) -
message is show but with additional information like "python" or
"Microsoft.Exploror.....":

   1. [image: image.png]
   [image: image.png]

How to hide is?

Here is my code:

import sys
from PyQt5 import QtCore, QtGui, QtWidgets


class SystemTrayIcon(QtWidgets.QSystemTrayIcon):

    def __init__(self, icon, parent=None):
        QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
        self.menu = QtWidgets.QMenu(parent)
        settingsAction = self.menu.addAction(self.tr("Settings..."))
        settingsAction.triggered.connect(self.settings)
        exitAction = self.menu.addAction(self.tr("Exit"))
        exitAction.triggered.connect(self.exit)
        self.setContextMenu(self.menu)
        self.show()
        self.showMessage("My app", "App started!", msecs=1000)

    def exit(self):
        QtCore.QCoreApplication.exit()
        self.showMessage("My app", "Quitting...", msecs=1000)
        self.hide()

    def settings(self):
        self.showMessage("My app", "Not implemented yet...", msecs=1000)


app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QWidget()
trayIcon = SystemTrayIcon(QtGui.QIcon('logo.ico'), widget)
sys.exit(app.exec_())


I use PyQt5-5.12.1-5.12.2-cp35.cp36.cp37.cp38-none-win_amd64.whl (on
Windows 10)

Zdenko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190401/a139a64a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 38803 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190401/a139a64a/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 47110 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190401/a139a64a/attachment-0003.png>


More information about the PyQt mailing list