当前位置: 首页>>代码示例>>Python>>正文


Python QtWidgets.QSystemTrayIcon方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QSystemTrayIcon方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QSystemTrayIcon方法的具体用法?Python QtWidgets.QSystemTrayIcon怎么用?Python QtWidgets.QSystemTrayIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets的用法示例。


在下文中一共展示了QtWidgets.QSystemTrayIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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) 
开发者ID:yarox24,项目名称:attack_monitor,代码行数:22,代码来源:system_tray_icon.py

示例2: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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 
开发者ID:kanishka-linux,项目名称:kawaii-player,代码行数:23,代码来源:traywidget.py

示例3: onTrayIconActivated

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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') 
开发者ID:kanishka-linux,项目名称:kawaii-player,代码行数:25,代码来源:traywidget.py

示例4: runcatCPU

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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_() 
开发者ID:CharlesPikachu,项目名称:Tools,代码行数:24,代码来源:runcat.py

示例5: runcatMemory

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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_() 
开发者ID:CharlesPikachu,项目名称:Tools,代码行数:24,代码来源:runcat.py

示例6: systemtray

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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) 
开发者ID:corrad1nho,项目名称:qomui,代码行数:20,代码来源:qomui_gui.py

示例7: make_sys_tray

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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) 
开发者ID:DoTheEvo,项目名称:ANGRYsearch,代码行数:16,代码来源:angrysearch.py

示例8: sys_tray_clicking

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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() 
开发者ID:DoTheEvo,项目名称:ANGRYsearch,代码行数:8,代码来源:angrysearch.py

示例9: on_systray_activated

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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 =====") 
开发者ID:mindfulness-at-the-computer,项目名称:mindfulness-at-the-computer,代码行数:17,代码来源:main_win.py

示例10: create_icon

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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() 
开发者ID:xmikos,项目名称:qhangups,代码行数:16,代码来源:__main__.py

示例11: icon_activated

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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()) 
开发者ID:xmikos,项目名称:qhangups,代码行数:13,代码来源:__main__.py

示例12: show_message

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
def show_message(self, title, msg, icon):
        self.showMessage(title, msg, icon)

        #QtWidgets.QSystemTrayIcon.Critical
        #winsound.PlaySound('sound\\Buzz-SoundBible.com-1790490578.wav', 0) 
开发者ID:yarox24,项目名称:attack_monitor,代码行数:7,代码来源:system_tray_icon.py

示例13: activatedEvent

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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() 
开发者ID:raelgc,项目名称:scudcloud,代码行数:8,代码来源:systray.py

示例14: is_system_tray_available

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
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 
开发者ID:borgbase,项目名称:vorta,代码行数:14,代码来源:utils.py

示例15: on_systemTrayIcon_activated

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
def on_systemTrayIcon_activated(self, reason):
        if reason == QtWidgets.QSystemTrayIcon.DoubleClick:
            self.parent.toggle_visibility() 
开发者ID:akej74,项目名称:grid-control,代码行数:5,代码来源:gridcontrol.py


注:本文中的PyQt5.QtWidgets.QSystemTrayIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。