Python PyQt5.QtWidgets.QSystemTrayIcon() Examples
The following are 21 code examples for showing how to use PyQt5.QtWidgets.QSystemTrayIcon(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
PyQt5.QtWidgets
, or try the search function
.
Example 1
Project: attack_monitor Author: yarox24 File: system_tray_icon.py License: GNU General Public License v3.0 | 6 votes |
def __init__(self, icon, parent, main_app, learning_mode): self.main_app = main_app QtWidgets.QSystemTrayIcon.__init__(self, parent) self.setIcon(icon) menu = QtWidgets.QMenu(parent) #LEARNING MODE menu_learning_action = menu.addAction("Learning mode") menu_learning_action.setCheckable(True) menu_learning_action.setChecked(learning_mode) menu_learning_action.toggled.connect(self.main_app.set_learning_mode) menu.addSeparator() #EXIT exitAction = menu.addAction("Exit") exitAction.triggered.connect(self.exit_zero) self.setContextMenu(menu)
Example 2
Project: kawaii-player Author: kanishka-linux File: traywidget.py License: GNU General Public License v3.0 | 6 votes |
def __init__(self, parent=None, ui_widget=None, home=None, window=None, logr=None): global ui, MainWindow, logger QtWidgets.QSystemTrayIcon.__init__(self, parent) ui = parent MainWindow = window logger = logr icon_img = os.path.join(home, 'src', 'tray.png') self.right_menu = RightClickMenuIndicator(ui_widget=ui_widget, window=window, logr=logr) self.setContextMenu(self.right_menu) self.activated.connect(self.onTrayIconActivated) self.p = QtGui.QPixmap(24, 24) self.p.fill(QtGui.QColor("transparent")) painter = QtGui.QPainter(self.p) if os.path.exists(icon_img): self.setIcon(QtGui.QIcon(icon_img)) else: self.setIcon(QtGui.QIcon("")) self.full_scr = 1 del painter
Example 3
Project: kawaii-player Author: kanishka-linux File: traywidget.py License: GNU General Public License v3.0 | 6 votes |
def onTrayIconActivated(self, reason): print(reason, '--reason--') if reason == QtWidgets.QSystemTrayIcon.Trigger: if not ui.float_window.isHidden(): ui.float_window.hide() self.right_menu.h_mode.setText('&Show') elif self.right_menu.d_vid.text().lower() == '&attach video': ui.float_window.show() self.right_menu.h_mode.setText('&Hide') else: if MainWindow.isHidden(): self.right_menu.h_mode.setText('&Hide') if ui.music_mode_dim_show: MainWindow.showNormal() MainWindow.setGeometry( ui.music_mode_dim[0], ui.music_mode_dim[1], ui.music_mode_dim[2], ui.music_mode_dim[3]) MainWindow.show() else: MainWindow.showMaximized() else: MainWindow.hide() self.right_menu.h_mode.setText('&Show')
Example 4
Project: Tools Author: CharlesPikachu File: runcat.py License: MIT License | 6 votes |
def runcatCPU(): app = QApplication(sys.argv) # 最后一个可视的窗口退出时程序不退出 app.setQuitOnLastWindowClosed(False) icon = QSystemTrayIcon() icon.setIcon(QIcon('icons/0.png')) icon.setVisible(True) cpu_percent = psutil.cpu_percent(interval=1) / 100 cpu_percent_update_fps = 20 fps_count = 0 while True: fps_count += 1 if fps_count > cpu_percent_update_fps: cpu_percent = psutil.cpu_percent(interval=1) / 100 fps_count = 0 # 开口向上的抛物线, 左边递减 time_interval = (cpu_percent * cpu_percent - 2 * cpu_percent + 2) / 20 for i in range(5): icon.setIcon(QIcon('icons/%d.png' % i)) icon.setToolTip('cpu: %.2f' % cpu_percent) time.sleep(time_interval) app.exec_()
Example 5
Project: Tools Author: CharlesPikachu File: runcat.py License: MIT License | 6 votes |
def runcatMemory(): app = QApplication(sys.argv) # 最后一个可视的窗口退出时程序不退出 app.setQuitOnLastWindowClosed(False) icon = QSystemTrayIcon() icon.setIcon(QIcon('icons/0.png')) icon.setVisible(True) memory_percent = psutil.virtual_memory().percent / 100 memory_percent_update_fps = 20 fps_count = 0 while True: fps_count += 1 if fps_count > memory_percent_update_fps: memory_percent = psutil.virtual_memory().percent / 100 fps_count = 0 # 开口向上的抛物线, 左边递减 time_interval = (memory_percent * memory_percent - 2 * memory_percent + 2) / 20 for i in range(5): icon.setIcon(QIcon('icons/%d.png' % i)) icon.setToolTip('memory: %.2f' % memory_percent) time.sleep(time_interval) app.exec_()
Example 6
Project: qomui Author: corrad1nho File: qomui_gui.py License: GNU General Public License v3.0 | 6 votes |
def systemtray(self): self.trayIcon = QtGui.QIcon.fromTheme("qomui") self.tray = QtWidgets.QSystemTrayIcon() if self.tray.isSystemTrayAvailable() == False: self.setWindowState(QtCore.Qt.WindowActive) self.showNormal() else: self.tray.setIcon(self.trayIcon) self.trayMenu = QtWidgets.QMenu() self.pop_tray_menu() self.tray.setContextMenu(self.trayMenu) self.tray.show() self.tray.setToolTip("Status: disconnected") self.tray.activated.connect(self.restoreUi) #if self.windowState() == QtCore.Qt.WindowActive: # self.trayMenu.insert(Action)
Example 7
Project: ANGRYsearch Author: DoTheEvo File: angrysearch.py License: GNU General Public License v2.0 | 5 votes |
def make_sys_tray(self): if Qw.QSystemTrayIcon.isSystemTrayAvailable(): menu = Qw.QMenu() menu.addAction('v1.0.1') menu.addSeparator() exitAction = menu.addAction('Quit') exitAction.triggered.connect(self.close) self.tray_icon = Qw.QSystemTrayIcon() self.tray_icon.setIcon(self.icon) self.tray_icon.setContextMenu(menu) self.tray_icon.show() self.tray_icon.setToolTip('ANGRYsearch') self.tray_icon.activated.connect(self.sys_tray_clicking)
Example 8
Project: ANGRYsearch Author: DoTheEvo File: angrysearch.py License: GNU General Public License v2.0 | 5 votes |
def sys_tray_clicking(self, reason): if (reason == Qw.QSystemTrayIcon.DoubleClick or reason == Qw.QSystemTrayIcon.Trigger): self.show() elif (reason == Qw.QSystemTrayIcon.MiddleClick): self.close()
Example 9
Project: mindfulness-at-the-computer Author: mindfulness-at-the-computer File: main_win.py License: GNU General Public License v3.0 | 5 votes |
def on_systray_activated(self, i_reason): # LXDE: # XFCE: # MacOS: logging.debug("===== on_systray_activated entered =====") logging.debug("i_reason = " + str(i_reason)) logging.debug("mouseButtons() = " + str(QtWidgets.QApplication.mouseButtons())) self.tray_icon.activated.emit(i_reason) """ if i_reason == QtWidgets.QSystemTrayIcon.Trigger: self.restore_window() else: self.tray_icon.activated.emit(i_reason) """ logging.debug("===== on_systray_activated exited =====")
Example 10
Project: qhangups Author: xmikos File: __main__.py License: GNU General Public License v3.0 | 5 votes |
def create_icon(self): """Create system tray icon""" self.trayIcon = QtWidgets.QSystemTrayIcon(self) self.iconActive = QtGui.QIcon("{}/qhangups.svg".format(os.path.dirname(os.path.abspath(__file__)))) self.iconDisabled = QtGui.QIcon("{}/qhangups_disabled.svg".format(os.path.dirname(os.path.abspath(__file__)))) # Workaround for Plasma 5 not showing SVG icons self.iconActive = QtGui.QIcon(self.iconActive.pixmap(128, 128)) self.iconDisabled = QtGui.QIcon(self.iconDisabled.pixmap(128, 128)) self.trayIcon.activated.connect(self.icon_activated) self.trayIcon.setContextMenu(self.trayIconMenu) self.trayIcon.setIcon(self.iconDisabled) self.trayIcon.setToolTip("QHangups") self.trayIcon.show()
Example 11
Project: qhangups Author: xmikos File: __main__.py License: GNU General Public License v3.0 | 5 votes |
def icon_activated(self, reason): """Connect or disconnect from Hangouts by double-click on tray icon""" if reason == QtWidgets.QSystemTrayIcon.Trigger or reason == QtWidgets.QSystemTrayIcon.DoubleClick: if self.icon_doubleclick_timer.isActive(): self.icon_doubleclick_timer.stop() if self.hangups_running: self.hangups_stop() else: self.hangups_start() else: self.icon_doubleclick_timer.start(QtWidgets.qApp.doubleClickInterval())
Example 12
Project: attack_monitor Author: yarox24 File: system_tray_icon.py License: GNU General Public License v3.0 | 5 votes |
def show_message(self, title, msg, icon): self.showMessage(title, msg, icon) #QtWidgets.QSystemTrayIcon.Critical #winsound.PlaySound('sound\\Buzz-SoundBible.com-1790490578.wav', 0)
Example 13
Project: scudcloud Author: raelgc File: systray.py License: MIT License | 5 votes |
def activatedEvent(self, reason): if reason in [QtWidgets.QSystemTrayIcon.MiddleClick, QtWidgets.QSystemTrayIcon.Trigger]: if self.window.isHidden() or self.window.isMinimized() or not self.window.isActiveWindow(): self.restore() else: self.window.hide()
Example 14
Project: vorta Author: borgbase File: utils.py License: GNU General Public License v3.0 | 5 votes |
def is_system_tray_available(): app = QApplication.instance() if app is None: app = QApplication([]) tray = QSystemTrayIcon() is_available = tray.isSystemTrayAvailable() app.quit() else: tray = QSystemTrayIcon() is_available = tray.isSystemTrayAvailable() return is_available
Example 15
Project: grid-control Author: akej74 File: gridcontrol.py License: GNU General Public License v3.0 | 5 votes |
def on_systemTrayIcon_activated(self, reason): if reason == QtWidgets.QSystemTrayIcon.DoubleClick: self.parent.toggle_visibility()
Example 16
Project: opensnitch Author: evilsocket File: service.py License: GNU General Public License v3.0 | 5 votes |
def _setup_tray(self): self._menu = QtWidgets.QMenu() self._stats_action = self._menu.addAction("Statistics") self._stats_action.triggered.connect(lambda: self._stats_dialog.show()) self._menu.addAction("Close").triggered.connect(self._on_exit) self._tray = QtWidgets.QSystemTrayIcon(self.off_icon) self._tray.setContextMenu(self._menu) self._tray.show()
Example 17
Project: v2rayL Author: jiangxufeng File: utils.py License: GNU General Public License v3.0 | 5 votes |
def __init__(self, w, app): self.app = app self.w = w QApplication.setQuitOnLastWindowClosed(False) # 禁止默认的closed方法, self.w.show() # 不设置显示则为启动最小化到托盘 self.tp = QSystemTrayIcon(self.w) self.initUI() self.run() # sys.stdout = EmittingStream(textWritten=self.w.output_ter_result) # sys.stderr = EmittingStream(textWritten=self.w.output_ter_result)
Example 18
Project: track Author: frans-fuerst File: mainwindow.py License: Apache License 2.0 | 5 votes |
def _initialize_tray_icon(self) -> QtWidgets.QSystemTrayIcon: def restore_window(reason: QtWidgets.QSystemTrayIcon.ActivationReason) -> None: if reason == QtWidgets.QSystemTrayIcon.DoubleClick: self.tray_icon.hide() self.showNormal() tray_icon = QtWidgets.QSystemTrayIcon(self) tray_icon.setIcon(self.windowIcon()) tray_icon.activated.connect(restore_window) return tray_icon
Example 19
Project: tinydecred Author: decred File: app.py License: ISC License | 5 votes |
def sysTrayActivated(self, trigger): """ Qt Slot called when the user interacts with the system tray icon. Shows the window, creating an icon in the user's application panel that persists until the appWindow is minimized. """ if trigger == QtWidgets.QSystemTrayIcon.Trigger: self.appWindow.show() self.appWindow.activateWindow()
Example 20
Project: Uranium Author: Ultimaker File: QtApplication.py License: GNU Lesser General Public License v3.0 | 4 votes |
def __init__(self, tray_icon_name: str = None, **kwargs) -> None: plugin_path = "" if sys.platform == "win32": if hasattr(sys, "frozen"): plugin_path = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "PyQt5", "plugins") Logger.log("i", "Adding QT5 plugin path: %s", plugin_path) QCoreApplication.addLibraryPath(plugin_path) else: import site for sitepackage_dir in site.getsitepackages(): QCoreApplication.addLibraryPath(os.path.join(sitepackage_dir, "PyQt5", "plugins")) elif sys.platform == "darwin": plugin_path = os.path.join(self.getInstallPrefix(), "Resources", "plugins") if plugin_path: Logger.log("i", "Adding QT5 plugin path: %s", plugin_path) QCoreApplication.addLibraryPath(plugin_path) # use Qt Quick Scene Graph "basic" render loop os.environ["QSG_RENDER_LOOP"] = "basic" super().__init__(sys.argv, **kwargs) # type: ignore self._qml_import_paths = [] #type: List[str] self._main_qml = "main.qml" #type: str self._qml_engine = None #type: Optional[QQmlApplicationEngine] self._main_window = None #type: Optional[MainWindow] self._tray_icon_name = tray_icon_name #type: Optional[str] self._tray_icon = None #type: Optional[str] self._tray_icon_widget = None #type: Optional[QSystemTrayIcon] self._theme = None #type: Optional[Theme] self._renderer = None #type: Optional[QtRenderer] self._job_queue = None #type: Optional[JobQueue] self._version_upgrade_manager = None #type: Optional[VersionUpgradeManager] self._is_shutting_down = False #type: bool self._recent_files = [] #type: List[QUrl] self._configuration_error_message = None #type: Optional[ConfigurationErrorMessage] self._http_network_request_manager = HttpRequestManager(parent = self) #Metadata required for the file dialogues. self.setOrganizationDomain("https://ultimaker.com/") self.setOrganizationName("Ultimaker B.V.")
Example 21
Project: launcher Author: getavalon File: app.py License: MIT License | 4 votes |
def init_tray(self): tray = QtWidgets.QSystemTrayIcon(self.windowIcon(), parent=self) tray.setToolTip("Avalon Launcher") # Build the right-mouse context menu for the tray icon menu = QtWidgets.QMenu() def window_show(): self.window.show() self.window.raise_() self.window.requestActivate() show = QtWidgets.QAction("Show", self) show.triggered.connect(window_show) menu.addAction(show) def on_quit(): # fix crash on quit with QML window open self.closeAllWindows() # fix tray icon remaining visible until hover over self._tray.hide() self.quit() quit = QtWidgets.QAction("Quit", self) quit.triggered.connect(on_quit) menu.addAction(quit) tray.setContextMenu(menu) # Add the double clicked behavior def on_tray_activated(reason): if reason == QtWidgets.QSystemTrayIcon.Context: return if self.window.isVisible(): self.window.hide() elif reason == QtWidgets.QSystemTrayIcon.Trigger: window_show() tray.activated.connect(on_tray_activated) self._tray = tray tray.show() tray.showMessage("Avalon", "Launcher tray started.", 500)