| 735 | |
| 736 | |
| 737 | class SystemTrayIcon(QtWidgets.QSystemTrayIcon): |
| 738 | |
| 739 | def __init__(self, icon, parent=None): |
| 740 | QtWidgets.QSystemTrayIcon.__init__(self, icon, parent) |
| 741 | self.setToolTip(f'Spectrum Security') |
| 742 | menu = QtWidgets.QMenu(parent) |
| 743 | |
| 744 | menu.addAction(QtGui.QIcon("icons/exit.png"), "Выйти", lambda: sys.exit()) |
| 745 | menu.addSeparator() |
| 746 | self.setContextMenu(menu) |
| 747 | self.activated.connect(self.onTrayIconActivated) |
| 748 | |
| 749 | def onTrayIconActivated(self, event): |
| 750 | if event == self.Trigger: # при одиночном клике ЛЕВОЙ КНОПКОЙ МЫШИ - показывает МЕНЮ |
| 751 | self.contextMenu().exec_(QtGui.QCursor.pos()) # показывает меню в текущей позиции мыши |
| 752 | |
| 753 | |
| 754 | |