from __future__ import annotations
import sys
from random import randint
from PySide6.QtCore import Slot
from PySide6.QtGui import QAction, QIcon
from PySide6.QtWidgets import QApplication, QMenu, QSystemTrayIcon
@Slot()
def demo_tray_action():
print('demo tray action', randint(999, 99999))
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)
tray = QSystemTrayIcon()
tray.setIcon(QIcon('/xxxxxx/ubuntu-plain-icon.svg'))
tray.setVisible(True)
tray.setToolTip('a tray app with ubuntu icon')
menu = QMenu()
action = QAction('DemoTrayAction')
action.triggered.connect(demo_tray_action)
menu.addAction(action)
tray_quit = QAction('TrayAppQuit')
tray_quit.triggered.connect(app.quit)
menu.addAction(tray_quit)
tray.setContextMenu(menu)
app.exec()
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。