A
A
Alex F2017-07-26 11:12:35
Python
Alex F, 2017-07-26 11:12:35

How to display PyQt5 QSystemTrayIcon tooltip?

Welcome all.
Available

the code
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout,\
 QWidget, QCheckBox, QSystemTrayIcon, QSpacerItem, QSizePolicy, QMenu, QAction,\
 QStyle, qApp, QMessageBox, QComboBox
from PyQt5.QtCore import QSize, QCoreApplication 
from PyQt5.QtGui import QIcon

class SystemTrayIcon(QSystemTrayIcon):
  tray_icon = True
  def __init__(self, icon, parent=None):
        QSystemTrayIcon.__init__(self, icon, parent)
        self.tray_icon = QSystemTrayIcon(self)
        menu = QMenu(parent)
        quit_action = QAction("Exit", self)
        menu.addAction(quit_action)
        quit_action.triggered.connect(qApp.quit)
        tray_menu = QMenu()
        self.iconLabel = QLabel("TEST")
        tray_menu.addAction(quit_action)
        self.setContextMenu(tray_menu)
        self.show()

def main():
    app = QApplication(sys.argv)
    w = QWidget()
    trayIcon = SystemTrayIcon(QIcon("~/pictures/icons/exit.png"), w)
    trayIcon.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()


Works like a clock. But I need to add a tooltip, but I won't give my mind how to do it.
Here , the docks are only in C ++.
Tell me please.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-07-26
@delvin-fil

trayIcon.setToolTip(u'Тест-проверка')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question