本文整理汇总了Python中PyQt5.QtWidgets.QSystemTrayIcon类的典型用法代码示例。如果您正苦于以下问题:Python QSystemTrayIcon类的具体用法?Python QSystemTrayIcon怎么用?Python QSystemTrayIcon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSystemTrayIcon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createTray
def _createTray(self):
from PyQt5.QtWidgets import QSystemTrayIcon
from PyQt5.QtGui import QIcon
from piony.common.system import expand_pj
tray = QSystemTrayIcon()
tray.setIcon(QIcon(expand_pj(":/res/tray-normal.png")))
tray.show()
return tray
示例2: __init__
def __init__(self, manager: Manager, icon, parent=None, testing=False) -> None:
QSystemTrayIcon.__init__(self, icon, parent)
self.setToolTip("ActivityWatch" + (" (testing)" if testing else ""))
self.manager = manager
self.testing = testing
self._build_rootmenu()
示例3: create_tray_icon
def create_tray_icon(self):
if QSystemTrayIcon.isSystemTrayAvailable():
logger.debug('System tray icon is available, showing')
self.tray_icon = QSystemTrayIcon(QIcon(':/i/xnova_logo_32.png'), self)
self.tray_icon.setToolTip(self.tr('XNova Commander'))
self.tray_icon.activated.connect(self.on_tray_icon_activated)
self.tray_icon.show()
else:
self.tray_icon = None
示例4: __init__
def __init__(self, icon, parent=None):
QSystemTrayIcon.__init__(self, icon, parent)
self.parent = parent
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.update)
self.timer.setSingleShot(True)
self.update()
示例5: __init__
def __init__(self, icon, com, parent=None):
QSystemTrayIcon.__init__(self, icon, parent)
menu = QMenu(parent)
showAction = menu.addAction("Mostrar")
showAction.triggered.connect(self.show_action)
exitAction = menu.addAction("Fechar")
exitAction.triggered.connect(self.close_event)
self.activated.connect(self.tray_activated)
self.setContextMenu(menu)
self.com = com
self.show()
示例6: __init__
def __init__(self, parent=None):
QSystemTrayIcon.__init__(self, parent=None)
# Initial state
self.set_disabled()
# Right Click
right_menu = RightClicked()
self.setContextMenu(right_menu)
# left click
self.activated.connect(self.toggle)
示例7: run
def run(manager, testing=False):
logger.info("Creating trayicon...")
# print(QIcon.themeSearchPaths())
app = QApplication(sys.argv)
# Without this, Ctrl+C will have no effect
signal.signal(signal.SIGINT, exit)
# Ensure cleanup happens on SIGTERM
signal.signal(signal.SIGTERM, exit)
timer = QtCore.QTimer()
timer.start(100) # You may change this if you wish.
timer.timeout.connect(lambda: None) # Let the interpreter run each 500 ms.
if not QSystemTrayIcon.isSystemTrayAvailable():
QMessageBox.critical(None, "Systray", "I couldn't detect any system tray on this system. Either get one or run the ActivityWatch modules from the console.")
sys.exit(1)
widget = QWidget()
icon = QIcon(":/logo.png")
trayIcon = TrayIcon(manager, icon, widget, testing=testing)
trayIcon.show()
trayIcon.showMessage("ActivityWatch", "ActivityWatch is starting up...")
QApplication.setQuitOnLastWindowClosed(False)
# Run the application, blocks until quit
return app.exec_()
示例8: __init__
def __init__(self, icon,parent=None):
QSystemTrayIcon.__init__(self,icon, parent)
menu = QMenu(parent)
showAction = menu.addAction("Show Moodly")
showAction.triggered.connect(self.trigger.emit)
exitAction = menu.addAction("Exit")
exitAction.triggered.connect(self.qtrigger.emit)
self.updateAction = menu.addAction("Update Now")
self.updateAction.triggered.connect(self.uptrigger.emit)
self.updateAction.setEnabled(False)
self.activated.connect(self.activateIcon)
self.setContextMenu(menu)
示例9: __init__
def __init__(self, *args):
super(DemoImpl, self).__init__(*args)
loadUi('dict2.ui',self)
self.setLayout(self.verticalLayout)
self.plainTextEdit.setReadOnly(True)
self.setWindowFlags(self.windowFlags() |
Qt.WindowSystemMenuHint |
Qt.WindowMinMaxButtonsHint)
self.trayicon = QSystemTrayIcon()
self.traymenu = QMenu()
self.quitAction = QAction('GQuit', self)
self.quitAction.triggered.connect(self.close)
self.quitAction.setShortcut(QKeySequence('Ctrl+q'))
self.addAction(self.quitAction)
self.traymenu.addAction('&Normal', self.showNormal, QKeySequence('Ctrl+n'))
self.traymenu.addAction('Mi&nimize', self.showMinimized, QKeySequence('Ctrl+i'))
self.traymenu.addAction('&Maximum', self.showMaximized, QKeySequence('Ctrl+m'))
self.traymenu.addAction('&Quit',self.close, QKeySequence('Ctrl+q'))
self.trayicon.setContextMenu(self.traymenu)
self.ticon = QIcon('icon_dict2.ico')
self.trayicon.setIcon(self.ticon)
self.trayicon.setToolTip('YYDict')
self.trayicon.activated.connect(self.on_systemTrayIcon_activated)
self.traymsg_firstshow = True
self.button1.clicked.connect(self.searchword)
self.comboBox.activated.connect(self.searchword)
示例10: __init__
def __init__(self):
super().__init__()
self.running = False
self.setWindowTitle('PySwicher v{}'.format(VERSION))
# Logging config
self.log_textbox = QPlainTextEditLogger(self)
logging.getLogger().addHandler(self.log_textbox)
self.log_textbox.setFormatter(logging.Formatter('[%(asctime)s][%(levelname)s]: %(message)s'))
self.log_textbox.setLevel(self.get_numeric_loglevel(options['log_level']))
self.log_to_file = False
# System tray configuration
self.tray_menu = QMenu(self)
self.systemTrayIcon = QSystemTrayIcon()
self.systemTrayIcon.setVisible(False)
self.systemTrayIcon.setIcon(QtGui.QIcon('C:\\Users\\Admin\\Pictures\\tray_stop.jpg'))
self.systemTrayIcon.activated.connect(self.sys_tray)
self.exit_action = self.tray_menu.addAction('Exit')
self.exit_action.triggered.connect(self.exit_app)
self.systemTrayIcon.setContextMenu(self.tray_menu)
self.click_tray_timer = QtCore.QTimer(self) # Fix for systemtray click trigger
self.click_tray_timer.setSingleShot(True)
self.click_tray_timer.timeout.connect(self.click_timeout)
self.main_window_ui()
self.starter()
示例11: start
def start():
# Start logging all events
if '--drop' in sys.argv:
drop_db()
utils.start_app_logging()
if sys.platform == 'win32':
from server import SingleInstance
single_app = SingleInstance()
if single_app.already_running():
running_warning()
app = QApplication(sys.argv)
if not QSystemTrayIcon.isSystemTrayAvailable():
QMessageBox.critical(
None,
"Systray",
"Could not detect a system tray on this system"
)
sys.exit(1)
QApplication.setQuitOnLastWindowClosed(False)
osf = OSFApp()
osf.start()
osf.hide()
sys.exit(app.exec_())
示例12: __init__
def __init__(self, *args):
super(QApplication, self).__init__(*args)
# Tray Icon
self._system_tray = QSystemTrayIcon()
self._system_tray.setIcon(QIcon('ui/icon.png'))
self._system_tray.setToolTip("Parse99")
self._system_tray.show()
# Settings
self.settings = settings.Settings("parse99")
# Plugins
self._plugins = {'maps': Maps(self.settings)}
# Timer
self._timer = QTimer()
self._timer.timeout.connect(self._parse)
# Thread
self._thread = None
# Menu
self._system_tray.setContextMenu(self._get_menu())
# File
self._log_file = ""
self._file_size = 0
self._last_line_read = 0
self._log_new_lines = []
# Start
self.toggle('on')
示例13: start_qt_app
def start_qt_app(config):
import sys
from PyQt5.QtWidgets import QApplication, QSystemTrayIcon, QMessageBox
from quamash import QEventLoop
from ui.main import Window
from ui.qt_gui_connection import qSignal
app = QApplication(sys.argv)
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
if not QSystemTrayIcon.isSystemTrayAvailable():
QMessageBox.critical(None, "Systray",
"I couldn't detect any system tray on this system.")
sys.exit(1)
QApplication.setQuitOnLastWindowClosed(False)
gui_connection = qSignal()
window = Window(gui_connection)
def closeApp():
print("Close app signal")
for task in asyncio.Task.all_tasks():
print(task)
task.cancel()
loop.stop()
gui_connection.closeApp.connect(closeApp)
with loop:
#asyncio.run_coroutine_threadsafe(timer(loop, config, gui_connection), loop)
try:
loop.run_until_complete(timer(loop, config, gui_connection))
except asyncio.CancelledError:
pass
示例14: __init__
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.connect_handlers()
# Sub Views
self.server_form = ServerForm()
self.server_form.set_main_window(self)
self.server_form.hide()
# Initiate empty list
self.data = []
self.notifications = []
# Refresh list
self.refresh_list()
# Set icons
icon = QtGui.QIcon(os.path.join(os.path.dirname(__file__), "icon.png"))
self.setWindowIcon(icon)
self.msgIcon = QSystemTrayIcon.MessageIcon(QSystemTrayIcon.Information)
self.systray_icon = QSystemTrayIcon(icon)
self.systray_icon.activated.connect(self.toggle_window)
self.systray_icon.show()
示例15: __init__
def __init__(self):
self._app = QApplication([sys.argv[0]])
from dbus.mainloop.pyqt5 import DBusQtMainLoop
super(Magneto, self).__init__(main_loop_class = DBusQtMainLoop)
self._window = QSystemTrayIcon(self._app)
icon_name = self.icons.get("okay")
self._window.setIcon(QIcon.fromTheme(icon_name))
self._window.activated.connect(self._applet_activated)
self._menu = QMenu(_("Magneto Entropy Updates Applet"))
self._window.setContextMenu(self._menu)
self._menu_items = {}
for item in self._menu_item_list:
if item is None:
self._menu.addSeparator()
continue
myid, _unused, mytxt, myslot_func = item
name = self.get_menu_image(myid)
action_icon = QIcon.fromTheme(name)
w = QAction(action_icon, mytxt, self._window,
triggered=myslot_func)
self._menu_items[myid] = w
self._menu.addAction(w)
self._menu.hide()