【发布时间】:2017-11-01 01:22:09
【问题描述】:
我正在使用 TrayIcon,我添加了一个“退出”QAction,现在,我想在单击 TrayIcon 菜单中的退出时执行某个功能。这是我的代码:
class TrayIcon(QSystemTrayIcon):
"""
Displays a system tray icon
"""
def __init__(self, interface: Interface) -> None:
"""
Constructor
:param interface: Interface to show when the tray icon is clicked
"""
super().__init__(QIcon(resource_filename("ezstorage.resources.img.tray_icon", "folder.png")))
self.interface = interface
self.setVisible(True)
self.show()
self.activated.connect(self.clicked)
menu = QMenu()
action = QAction("Exit")
menu.addAction(action)
self.setContextMenu(menu)
【问题讨论】: