本文整理汇总了Python中PyQt5.QtWidgets.QSystemTrayIcon.show方法的典型用法代码示例。如果您正苦于以下问题:Python QSystemTrayIcon.show方法的具体用法?Python QSystemTrayIcon.show怎么用?Python QSystemTrayIcon.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSystemTrayIcon
的用法示例。
在下文中一共展示了QSystemTrayIcon.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Icon
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class Icon(QWidget):
def __init__(self, app, newEntry, listWin):
super().__init__()
self.newEntry = newEntry
self.listWin = listWin
self.app = app
self.initUI()
def initUI(self):
menu = QMenu()
Ajouter = QAction(QIcon(''), '&Ajouter un tag', menu)
Ajouter.triggered.connect(self.newEntry.show)
menu.addAction(Ajouter)
ouvrir = QAction(QIcon(''), '&Ouvrir', menu)
ouvrir.triggered.connect(self.listWin.show)
menu.addAction(ouvrir)
Quitter = QAction(QIcon(''), '&Quitter', menu)
Quitter.triggered.connect(self.app.exit)
menu.addAction(Quitter)
self.icon = QSystemTrayIcon()
self.icon.setIcon(QIcon('./icone.png'))
self.icon.setContextMenu(menu)
self.icon.show()
示例2: _createTray
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
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
示例3: SystemTray
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class SystemTray(QWidget):
def __init__(self, parent=None):
super(SystemTray, self).__init__(parent)
self.tray_icon_menu = QMenu(self)
self.tray_icon = QSystemTrayIcon(self)
self.tray_icon.setContextMenu(self.tray_icon_menu)
self.icon_management = IconManagement(self.tray_icon)
self.connection_handler = ConnectionHandler(FREQUENCY_CHECK_MS, TIME_OUT_CALL_S, self)
self.connection_handler.value_changed.connect(self.internet_connection)
self.connection_handler.start()
def add_action(self, name, triggered_action):
action = QAction(QCoreApplication.translate(trad_context, name), self, triggered = triggered_action)
self.tray_icon_menu.addAction(action)
def add_separator(self):
self.tray_icon_menu.addSeparator()
def show(self):
super(SystemTray, self).show()
self.tray_icon.show()
@pyqtSlot()
def event_started(self):
self.icon_management.start()
@pyqtSlot()
def event_finished(self):
self.icon_management.stop()
@pyqtSlot(Exception)
def conductor_problem(self, e):
self.notify("Demerio", "There was a problem : %s" % (e,))
self.icon_management.conductor_problem()
@pyqtSlot(bool)
def internet_connection(self, internet_is_ok):
if not internet_is_ok:
self.notify("Demerio", "Internet connection is lost")
self.icon_management.internet_is_ok(internet_is_ok)
def notify(self, title, message):
self.tray_icon.showMessage(title, message, BAR_NOTIFICATION_TIME)
示例4: Window
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class Window(QMainWindow):
"""
Main GUI class for application
"""
def __init__(self):
QWidget.__init__(self)
# loaind ui from xml
uic.loadUi(os.path.join(DIRPATH, 'app.ui'), self)
# self.show_msgbox("Info", "Lan Messenger")
self.users = {}
self.host = socket.gethostname()
self.ip = get_ip_address()
# button event handlers
self.btnRefreshBuddies.clicked.connect(self.refreshBuddies)
self.btnSend.clicked.connect(self.sendMsg)
self.lstBuddies.currentItemChanged.connect(
self.on_buddy_selection_changed)
self.msg_manager = MessageManager()
self.msg_sender = MessageSender(self.host, self.ip)
self.message_listener = MessageListener()
self.message_listener.message_received.connect(self.handle_messages)
self.send_IAI()
self.setup_tray_menu()
# setting up handlers for menubar actions
self.actionAbout.triggered.connect(self.about)
self.actionExit.triggered.connect(qApp.quit)
self.actionPreferences.triggered.connect(self.show_preferences)
def about(self):
print("about")
ad = AboutDialog()
ad.display()
def show_preferences(self):
print("preferences")
pd = PrefsDialog()
pd.display()
def setup_tray_menu(self):
# setting up QSystemTrayIcon
self.tray_icon = QSystemTrayIcon(self)
self.tray_icon.setIcon(
self.style().standardIcon(QStyle.SP_ComputerIcon))
# tray actions
show_action = QAction("Show", self)
quit_action = QAction("Exit", self)
hide_action = QAction("Hide", self)
# action handlers
show_action.triggered.connect(self.show)
hide_action.triggered.connect(self.hide)
quit_action.triggered.connect(qApp.quit)
# tray menu
tray_menu = QMenu()
tray_menu.addAction(show_action)
tray_menu.addAction(hide_action)
tray_menu.addAction(quit_action)
self.tray_icon.setContextMenu(tray_menu)
self.tray_icon.show()
def closeEvent(self, event):
event.ignore()
self.hide()
self.tray_icon.showMessage(
"PyLanMessenger",
"PyLanMessenger was minimized to Tray",
QSystemTrayIcon.Information,
2000
)
def handle_messages(self, data):
log.debug("UI handling message: %s" % data)
pkt = Packet()
pkt.json_to_obj(data)
if pkt.op == "IAI":
self.handle_IAI(pkt.ip, pkt.host)
if pkt.op == "MTI":
self.handle_MTI(pkt.ip, pkt.host)
if pkt.op == "TCM":
self.handle_TCM(pkt.ip, pkt.host, pkt.msg)
def send_IAI(self):
# broadcast a message that IAI - "I Am In" the n/w
pkt = Packet(op="IAI", ip=self.ip, host=self.host).to_json()
self.msg_sender.send_broadcast_message(pkt)
#.........这里部分代码省略.........
示例5: initUI
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
#.........这里部分代码省略.........
self.prevBtn.setStyleSheet("QPushButton{ border-image:url(image/newimg/statusbar_btn_prev.png);border:none } QPushButton:hover{ border-image:url(image/newimg/statusbar_btn_prev_2.png)}")
# 播放模式
self.playmodel = QPushButton("",songer_img)
self.playmodel.setGeometry(35,156,25,25)
self.playmodel.setStyleSheet("QPushButton{ border-image:url(image/newimg/allmodel.png);border:none } QPushButton:hover{ border-image:url(image/newimg/allmodel_2.png)}")
self.playmodel.clicked.connect(self.moshi)
# 当前播放时间
self.songTime = QLabel("",self)
self.songTime.setGeometry(240,180,80,20)
self.songTime.setStyleSheet("QLabel{ color:#AAA;font-size:12px;}")
self.songTime.setAlignment(Qt.AlignHCenter)
# 当前歌曲名
self.currentMusicName = QLabel("",songer_img)
self.currentMusicName.setGeometry(0,180,200,20)
self.currentMusicName.setStyleSheet("QLabel{ color:white ;font-weight:100;font-size:12px;margin-left:5px;}")
# 歌曲进度条
self.processSlider = QSlider(Qt.Horizontal,self)
self.processSlider.setGeometry(0,193,300,7)
# self.processSlider.setRange(1,100)
self.processSlider.setValue(0)
self.processSlider.setStyleSheet(qss_process_slider)
self.processSlider.setCursor(QCursor(Qt.UpArrowCursor))
# 歌曲列表 ---------------------------
listWgt = QWidget(self)
listWgt.setGeometry(0, 200, 300,380)
listWgt.setStyleSheet(qss_scrollbar)
#列表
self.songList = QListWidget(listWgt)
self.songList.setGeometry(5,0,235,380)
self.songList.setStyleSheet(qss_songlist)
# 列表添加右键菜单
# self.songList.setContextMenuPolicy(Qt.CustomContextMenu)
# self.songList.customContextMenuRequested.connect(self.rightMenuShow)
#歌曲列表右边的功能列表
funcList = QListWidget(listWgt)
funcList.setGeometry(240,0,55,380)
funcList.setStyleSheet(qss_menu)
btn = QPushButton("",funcList)
btn.clicked.connect(self.newwindow)
btn.setGeometry(15,10,30,30)
btn.setStyleSheet("QPushButton{ border-image:url(image/home.png)} \
QPushButton:hover{ border-image:url(image/homehover.png) }")
# btn.setCursor(QCursor(Qt.PointingHandCursor))
btn = QPushButton("",funcList)
btn.setGeometry(15,60,30,30)
btn.setStyleSheet("QPushButton{ border-image:url(image/tuijian.png) } \
QPushButton:hover{ border-image:url(image/tuijianhover.png) }")
# btn.setCursor(QCursor(Qt.PointingHandCursor))
btn = QPushButton("",funcList)
btn.setGeometry(15,100,30,30)
btn.setStyleSheet("QPushButton{ border-image:url(image/shoucang.png) }\QPushButton:hover{ border-image:url(image/shoucanghover.png) }")
# btn.setCursor(QCursor(Qt.PointingHandCursor))
btn = QPushButton("",funcList)
btn.setGeometry(15,140,30,30)
btn.setStyleSheet("QPushButton{ border-image:url(image/rizhi.png) }\
QPushButton:hover{ border-image:url(image/rizhihover.png) }")
# btn.setCursor(QCursor(Qt.PointingHandCursor))
btn = QPushButton("",funcList)
btn.setGeometry(17,180,30,30)
btn.setStyleSheet("QPushButton{ border-image:url(image/mv.png) }\
QPushButton:hover{ border-image:url(image/mvhover.png) }")
# btn.setCursor(QCursor(Qt.PointingHandCursor))
setbtn = QPushButton("",funcList)
setbtn.setGeometry(15,225,33,33)
setbtn.setStyleSheet("QPushButton{ border-image:url(image/settinghover.png) }\
QPushButton:hover{ border-image:url(image/setting.png) }")
setbtn.clicked.connect(self.openseting)
#底部状态栏
wg = QWidget(self)
wg.setGeometry(0, 580, 300,20)
wg.setStyleSheet("QWidget{ background:#2D2D2D; } ")
# ql = QLabel(" <a style='color:#444;text-decoration:none;font-size:12px;' href ='https://github.com/codeAB/music-player' >S Y L </a>",wg)
# ql.resize(300,20)
# ql.setAlignment(Qt.AlignRight)
# ql.linkActivated.connect(self.openurl)
#设置托盘图标
tray = QSystemTrayIcon(self)
tray.setIcon(QIcon('image/tray.png'))
self.trayIconMenu = QMenu(self)
self.trayIconMenu.setStyleSheet(qss_tray)
showAction = QAction(QIcon('image/tray.png'),u"显示主面板", self,triggered=self.show)
self.trayIconMenu.addAction(showAction)
# self.trayIconMenu.addAction(preAction)
# self.trayIconMenu.addAction(pauseAction)
# self.trayIconMenu.addAction(nextAction)
# self.trayIconMenu.addAction(quitAction)
tray.setContextMenu(self.trayIconMenu)
tray.show()
tray.activated.connect(self.dbclick_tray)
示例6: MainApp
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class MainApp(QMainWindow, Ui_MainWindow):
_translate = QCoreApplication.translate
tab_list = []
# TODO - add dutch translation files
def __init__(self, isolated, *args):
super(MainApp, self).__init__(*args)
Lumberjack.info('spawning the <<< MainApp >>> hey says: I am the Main man here see!')
self.load_settings()
self.setup_tray(isolated)
self.dbhelper = DbHelper()
self.setupUi(self)
self.iconize_controls()
self.load_styling()
self.tabWidget = QTabWidget(self.centralwidget)
self.tabWidget.setTabsClosable(True)
self.tabWidget.setMovable(True)
self.tabWidget.setTabBarAutoHide(True)
self.tabWidget.setObjectName("tabWidget")
self.verticalLayout.addWidget(self.tabWidget)
builderLabel = QLabel('made by: MazeFX Solutions')
self.statusbar.addPermanentWidget(builderLabel)
self.menuPAT.triggered.connect(self.handle_menu_event)
self.menuLists.triggered.connect(self.handle_menu_event)
self.menuHelp.triggered.connect(self.handle_menu_event)
self.tabWidget.tabCloseRequested.connect(self.close_tab)
self.actionHome.trigger()
self._retranslateUi(self)
def iconize_controls(self):
Lumberjack.info('< MainApp > - -> (iconize_controls)')
homeIcon = qta.icon('fa.home', color='white')
self.actionHome.setIcon(homeIcon)
wrenchIcon = qta.icon('fa.wrench', color='white')
self.actionSettings.setIcon(wrenchIcon)
bankIcon = qta.icon('fa.bank', color='white')
self.actionListBankAccounts.setIcon(bankIcon)
contractIcon = QIcon(':/app_icons/rc/handshake_icon.svg')
self.actionListContracts.setIcon(contractIcon)
atIcon = qta.icon('fa.at', color='white')
self.actionListEmailAddresses.setIcon(atIcon)
envelopeIcon = qta.icon('fa.envelope', color='white')
self.actionListLetters.setIcon(envelopeIcon)
relationIcon = qta.icon('fa.group', color='white')
self.actionListRelations.setIcon(relationIcon)
transactionIcon = qta.icon('fa.money', color='white')
self.actionListTransactions.setIcon(transactionIcon)
userIcon = qta.icon('fa.user', color='white')
self.actionListUsers.setIcon(userIcon)
helpIcon = qta.icon('fa.question', color='white')
self.actionHelp.setIcon(helpIcon)
aboutIcon = qta.icon('fa.info', color='white')
self.actionAbout.setIcon(aboutIcon)
def setup_tray(self, isolated):
Lumberjack.info('< MainApp > - -> (setup_tray)')
self.trayIcon = QSystemTrayIcon(QIcon(':/app_icons/rc/PAT_icon.png'), self)
self.trayMenu = QMenu(self)
showAction = self.trayMenu.addAction("Open PAT")
self.trayMenu.addSeparator()
exitAction = self.trayMenu.addAction("Exit")
self.trayIcon.setContextMenu(self.trayMenu)
self.trayMenu.triggered.connect(self.handle_tray_event)
self.trayIcon.activated.connect(self.handle_tray_event)
self.trayIcon.show()
if isolated:
self.trayIcon.showMessage('PAT Service', 'PAT service is now running..')
def handle_tray_event(self, *args):
Lumberjack.info('< MainApp > - -> (handle_tray_event)')
print(Fore.MAGENTA + '$! Received a tray action with args: ', args)
if args[0] == 3:
self.show()
return
elif hasattr(args[0], 'text'):
print(Fore.MAGENTA + '$! Tray event has text!!')
if args[0].text() == 'Open PAT':
self.show()
elif args[0].text() == 'Exit':
self.close()
def _retranslateUi(self, MainWindow):
pass
#.........这里部分代码省略.........
示例7: Sansimera
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class Sansimera(QMainWindow):
def __init__(self, parent=None):
super(Sansimera, self).__init__(parent)
self.settings = QSettings()
self.timer = QTimer(self)
self.timer_reminder = QTimer(self)
self.timer_reminder.timeout.connect(self.reminder_tray)
interval = self.settings.value('Interval') or '1'
if interval != '0':
self.timer_reminder.start(int(interval) * 60 * 60 * 1000)
self.tentatives = 0
self.gui()
self.lista = []
self.lista_pos = 0
self.eortazontes_shown = False
self.eortazontes_names = ''
def gui(self):
self.systray = QSystemTrayIcon()
self.icon = QIcon(':/sansimera.png')
self.systray.setIcon(self.icon)
self.systray.setToolTip('Σαν σήμερα...')
self.menu = QMenu()
self.exitAction = QAction('&Έξοδος', self)
self.refreshAction = QAction('&Ανανέωση', self)
self.aboutAction = QAction('&Σχετικά', self)
self.notification_interval = QAction('Ει&δοποίηση εορταζόντων', self)
self.menu.addAction(self.notification_interval)
self.menu.addAction(self.refreshAction)
self.menu.addAction(self.aboutAction)
self.menu.addAction(self.exitAction)
self.systray.setContextMenu(self.menu)
self.notification_interval.triggered.connect(self.interval_namedays)
self.exitAction.triggered.connect(exit)
self.refreshAction.triggered.connect(self.refresh)
self.aboutAction.triggered.connect(self.about)
self.browser = QTextBrowser()
self.browser.setOpenExternalLinks(True)
self.setGeometry(600, 500, 400, 300)
self.setWindowIcon(self.icon)
self.setWindowTitle('Σαν σήμερα...')
self.setCentralWidget(self.browser)
self.systray.show()
self.systray.activated.connect(self.activate)
self.browser.append('Λήψη...')
nicon = QIcon(':/next')
picon = QIcon(':/previous')
ricon = QIcon(':/refresh')
iicon = QIcon(':/info')
qicon = QIcon(':/exit')
inicon = QIcon(':/notifications')
self.nextAction = QAction('Επόμενο', self)
self.nextAction.setIcon(nicon)
self.previousAction = QAction('Προηγούμενο', self)
self.refreshAction.triggered.connect(self.refresh)
self.nextAction.triggered.connect(self.nextItem)
self.previousAction.triggered.connect(self.previousItem)
self.previousAction.setIcon(picon)
self.refreshAction.setIcon(ricon)
self.exitAction.setIcon(qicon)
self.aboutAction.setIcon(iicon)
self.notification_interval.setIcon(inicon)
controls = QToolBar()
self.addToolBar(Qt.BottomToolBarArea, controls)
controls.setObjectName('Controls')
controls.addAction(self.previousAction)
controls.addAction(self.nextAction)
controls.addAction(self.refreshAction)
self.restoreState(self.settings.value("MainWindow/State", QByteArray()))
self.refresh()
def interval_namedays(self):
dialog = sansimera_reminder.Reminder(self)
dialog.applied_signal['QString'].connect(self.reminder)
if dialog.exec_() == 1:
print('Apply namedays reminder interval...')
def reminder(self, time):
self.settings.setValue('Interval', time)
if time != '0':
self.timer_reminder.start(int(time) * 60 * 60 * 1000)
print('Reminder = ' + time + ' hour(s)')
else:
print('Reminder = None')
def nextItem(self):
if len(self.lista) >= 1:
self.browser.clear()
if self.lista_pos != len(self.lista)-1:
self.lista_pos += 1
else:
self.lista_pos = 0
self.browser.append(self.lista[self.lista_pos])
self.browser.moveCursor(QTextCursor.Start)
else:
return
def previousItem(self):
if len(self.lista) >= 1:
self.browser.clear()
#.........这里部分代码省略.........
示例8: Magneto
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class Magneto(MagnetoCore):
"""
Magneto Updates Notification Applet class.
"""
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()
def _first_check(self):
def _do_check():
self.send_check_updates_signal(startup_check = True)
return False
if self._dbus_service_available:
const_debug_write("_first_check", "spawning check.")
QTimer.singleShot(10000, _do_check)
def startup(self):
self._dbus_service_available = self.setup_dbus()
if config.settings["APPLET_ENABLED"] and \
self._dbus_service_available:
self.enable_applet(do_check = False)
const_debug_write("startup", "applet enabled, dbus service available.")
else:
const_debug_write("startup", "applet disabled.")
self.disable_applet()
if not self._dbus_service_available:
const_debug_write("startup", "dbus service not available.")
QTimer.singleShot(30000, self.show_service_not_available)
else:
const_debug_write("startup", "spawning first check.")
self._first_check()
# Notice Window instance
self._notice_window = AppletNoticeWindow(self)
self._window.show()
# Enter main loop
self._app.exec_()
def close_service(self):
super(Magneto, self).close_service()
self._app.quit()
def change_icon(self, icon_name):
name = self.icons.get(icon_name)
self._window.setIcon(QIcon.fromTheme(name))
def disable_applet(self, *args):
super(Magneto, self).disable_applet()
self._menu_items["disable_applet"].setEnabled(False)
self._menu_items["enable_applet"].setEnabled(True)
def enable_applet(self, w = None, do_check = True):
done = super(Magneto, self).enable_applet(do_check = do_check)
if done:
self._menu_items["disable_applet"].setEnabled(True)
self._menu_items["enable_applet"].setEnabled(False)
def show_alert(self, title, text, urgency = None, force = False,
buttons = None):
# NOTE: there is no support for buttons via QSystemTrayIcon.
if ((title, text) == self.last_alert) and not force:
return
def _action_activate_cb(action_num):
if not buttons:
return
#.........这里部分代码省略.........
示例9: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class MainWindow(QMainWindow):
restartOdooMenuItem = QtCore.pyqtSignal()
stopOdooMenuItem = QtCore.pyqtSignal()
restartPostgreMenuItem = QtCore.pyqtSignal()
stopPostgreMenuItem = QtCore.pyqtSignal()
def __init__(self):
super(MainWindow, self).__init__()
if OdooInstallationFound == False:
if not os.path.isdir(appfolder + '\\Temp'):
os.makedirs(appfolder + '\\Temp')
unzipToPath = appfolder + '\\Temp\\Unzip'
destinationPath = appfolder + "\\Runtime\\Odoo"
self.downloadFileWorker(mainSettings['github']['downloadPath'])
if os.path.isfile(appfolder + '\\Temp\\GitHub-Odoo.zip'):
if not os.path.isdir(appfolder + '\\Temp\\unzip'):
os.makedirs(appfolder + '\\Temp\\unzip')
self.zipFileWorker(appfolder + '\\Temp\\GitHub-Odoo.zip', unzipToPath)
self.zipWindow.close()
#Check if the file is etxracted to subfolder - Files on github includes branch name -> Correct this
countFolders = 0
extractFolder = None
for name in os.listdir(unzipToPath):
extractFolder = name
countFolders += 1
if countFolders == 1:
shutil.move(unzipToPath + "\\" + extractFolder + "\\", destinationPath)
self.startCybeSystemsApplication()
else:
self.startCybeSystemsApplication()
if os.path.isdir(appfolder + '\\Temp'):
shutil.rmtree(appfolder + '\\Temp',ignore_errors=True)
def zipFileWorker(self,file, destination_folder):
self.zipWindow = ZipWindow(file, destination_folder)
self.zipWindow.show()
def downloadFileWorker(self,url):
self.httpWin = HttpWindow(url)
self.httpWin.exec()
def startCybeSystemsApplication(self):
#Set Loading TrayIcon
self.setWindowIcon(QtGui.QIcon(appfolder + '/ressource/icons/icon.png'))
img = QtGui.QImage()
img.load(appfolder + '/ressource/icons/icon_loading.png')
self.pixmap = QtGui.QPixmap.fromImage(img)
self.icon = QtGui.QIcon()
self.icon.addPixmap(self.pixmap)
self.tray = QSystemTrayIcon(self.icon, self)
self.tray.show()
traymenu = QMenu()
#Set Real Icon
self.tray.hide()
img = QtGui.QImage()
img.load(appfolder + '/ressource/icons/icon.png')
self.pixmap = QtGui.QPixmap.fromImage(img)
self.icon = QtGui.QIcon()
self.icon.addPixmap(self.pixmap)
self.tray = QSystemTrayIcon(self.icon, self)
self.tray.activated.connect(self.onTrayIconActivated)
self.tray.setContextMenu(traymenu)
self.tray.show()
#Load Stylesheet
if mainSettings['other']['theme'].lower() != 'default':
if mainSettings['other']['theme'].lower() == 'steamlike':
stylesheetFile = open(appfolder + '/ressource/ui/steamlike.stylesheet', "r")
elif mainSettings['other']['theme'].lower() == 'darkorange':
stylesheetFile = open(appfolder + '/ressource/ui/darkorange.stylesheet', "r")
elif mainSettings['other']['theme'].lower() == 'maya':
stylesheetFile = open(appfolder + '/ressource/ui/maya.stylesheet', "r")
stylesheet = stylesheetFile.read()
traymenu.setStyleSheet(stylesheet)
stylesheetFile.close()
trayoption_openBrowser_entry = QAction(QtGui.QIcon(self.icon), "Open Odoo", self)
trayoption_openBrowser_entry.triggered.connect(lambda: webbrowser.open(mainSettings['odoo']['startpage']))
traymenu.addAction(trayoption_openBrowser_entry)
trayoption_openBrowser_entry.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/world.png'))
traymenu.addSeparator()
tools = traymenu.addMenu('&Odoo')
tools.setIcon(QtGui.QIcon(appfolder + '/ressource/icons/icon.png'))
tools_odoo_restart = QAction(QtGui.QIcon(self.icon), "Restart Server", self)
tools_odoo_restart.triggered.connect(lambda: (self.restartOdooMenuItem.emit()))
#.........这里部分代码省略.........
示例10: Parse99
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class Parse99(QApplication):
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')
def _settings_valid(self):
valid = True
if self.settings.get_value('general', 'first_run') is None:
self._system_tray.showMessage(
"Parse99",
"""It looks like this is the first time the program is being
run. Please setup the application using the Settings option
once you right click the system tray icon."""
)
self.edit_settings()
self.settings.set_value('general', 'first_run', True)
valid = False
elif self.settings.get_value('general', 'eq_directory') is None:
self._system_tray.showMessage(
"Parse99",
"Please enter the General settings and \
choose the location of your Everquest Installation."
)
self.edit_settings()
valid = False
elif self.settings.get_value('characters', None) is None:
self._system_tray.showMessage(
"Parse99",
"No characters have been made. \
Please create at least one character using settings."
)
self.edit_settings(tab="characters")
valid = False
elif self.settings.get_value('general', 'current_character') is None:
self._system_tray.showMessage(
"Parse99",
"No character has been selected. \
Please choose a character from the Character menu."
)
valid = False
return valid
def toggle(self, switch):
if switch == 'off':
if self._thread is not None:
self._timer.stop()
self._thread.stop()
self._thread.join()
elif switch == 'on':
if self._settings_valid():
characters = self.settings.get_value('characters', None)
log_file = characters[
self.settings.get_value('general', 'current_character')
]['log_file']
self._thread = FileReader(
log_file,
int(self.settings.get_value('general', 'parse_interval'))
)
self._thread.start()
self._timer.start(
1000 *
int(self.settings.get_value('general', 'parse_interval'))
)
def _parse(self):
for line in self._thread.get_new_lines():
for plugin in self._plugins.keys():
if self._plugins[plugin].is_active():
self._plugins[plugin].parse(line)
#.........这里部分代码省略.........
示例11: gerar_cpf
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
from PyQt5.QtGui import QIcon, QClipboard, QKeySequence
import cpf
def gerar_cpf():
clip = QApplication.clipboard()
clip.setText(cpf.gerar_cpf(False))
def gerar_cpf_formatado():
clip = QApplication.clipboard()
clip.setText(cpf.gerar_cpf(True))
def buscar_ip():
clip = QApplication.clipboard()
clip.setText(ipgetter.myip())
if __name__ == '__main__':
app = QApplication([])
icon = QSystemTrayIcon(QIcon("img/icon.png"))
menu = QMenu()
menu.addAction("Gerar cpf sem formatação", gerar_cpf)
menu.addAction("Gerar cpf com formatação", gerar_cpf_formatado)
menu.addSeparator()
menu.addAction("Buscar id público", buscar_ip)
menu.addSeparator()
menu.addAction("Fechar", app.quit)
icon.setContextMenu(menu)
icon.show()
app.exec_()
示例12: Window
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class Window(QWidget):
w, h = 0, 0
layoutmode = False
movetile = None
ismin = False
tiles = []
def __init__(self):
super().__init__()
if TRAY_ICON:
self.inittray()
self.setWindowTitle('Tilemenu')
self.initgeometry()
self.inittiles()
self.mouseReleaseEvent = self.onClicked
self.initstyle()
self.show()
def inittiles(self):
for t in TILESET:
newtile = t.tile(t.xy, parent=self, extra=t.extra)
self.tiles.append(newtile)
def testinittiles(self):
for i in range(self.w):
for j in range(self.h):
self.tiles.append(RndColor((i, j), parent=self))
self.tiles[0] = Close((-1, 0), parent=self)
self.tiles[1] = DesktopEntry((1, 1), (2, "gedit --new-window", "icons/gedit.png"), self)
def initgeometry(self):
self.w = (QApplication.desktop().width() - XPOS - XOFF) // (SUNIT)
self.h = (QApplication.desktop().height() - YPOS - YOFF) // (SUNIT)
if ALIGN == 'LB':
self.dw = 0
self.dh = (QApplication.desktop().height() - YPOS - YOFF) % (SUNIT)
elif ALIGN == 'RT':
self.dw = (QApplication.desktop().width() - XPOS - XOFF) % (SUNIT)
self.dh = 0
elif ALIGN == 'RB':
self.dw = (QApplication.desktop().width() - XPOS - XOFF) % (SUNIT)
self.dh = (QApplication.desktop().height() - YPOS - YOFF) % (SUNIT)
else:
self.dw = 0
self.dh = 0
self.usegeometry()
def usegeometry(self):
self.move(XPOS + self.dw, YPOS + self.dh)
self.setFixedSize(self.w * SUNIT + SPC, self.h * SUNIT + SPC)
def hideAll(self):
for i in range(1, len(self.tiles)):
self.tiles[i].hide()
def showAll(self):
for i in range(1, len(self.tiles)):
self.tiles[i].show()
def initstyle(self):
self.setWindowIcon(QIcon('icon.gif'))
self.setcolort(BACKGROUND_COLOR)
if not TESTMODE:
self.setWindowFlags(Qt.FramelessWindowHint |
Qt.NoDropShadowWindowHint |
Qt.WindowStaysOnBottomHint)
elif TESTMODE == 1:
self.setWindowFlags(Qt.FramelessWindowHint |
Qt.NoDropShadowWindowHint)
elif TESTMODE == 2:
pass
if BACKGROUND_TRANSPARENT:
self.setAutoFillBackground(False)
self.setAttribute(Qt.WA_TranslucentBackground)
if FULSCREEN:
self.showFullScreen()
def setcolort(self, colort):
self.colort = colort
self.setStyleSheet("background-color:rgba" + self.colort + ";")
def onClicked(self, event):
if self.layoutmode and self.movetile != None:
self.movetile.x = (self.cursor().pos().x() - self.x()) // SUNIT
self.movetile.y = (self.cursor().pos().y() - self.y()) // SUNIT
self.movetile.move(self.movetile.x * SUNIT + SPC, self.movetile.y * SUNIT + SPC)
self.movetile.sethold(0, self.movetile.dragholdcolor)
self.movetile.movemode = False
self.movetile = None
def keyPressEvent(self, event):
if event.key() == Qt.Key_Delete and self.layoutmode:
self.movetile.close()
self.tiles.remove(self.movetile)
self.movetile = None
self.repaint()
else:
pass
def genImports(self, filename):
#.........这里部分代码省略.........
示例13: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class MainWindow(QMainWindow):
"""The main GUI application."""
def __init__(self, config):
"""Initializer for the GUI widgets. Pass in an instance of Config class, so that it may interact with the config."""
super().__init__()
self.config = config
self.setWindowTitle("Livestreamer GUI v{}".format(APPVERSION))
self.setup_systray()
self.setup_menu()
self.setup_geometry()
self.livestreamer_thread = None
self.thread_exit_grace_time = 10000 # How long a thread can take to exit in milliseconds
self.timestamp_format = self.config.get_config_value("timestamp-format")
self.setup_control_widgets()
self.update_colors()
# Load all streaming-related data
self.selections = {"streamer": None, "channel": None}
self.load_streamers()
self.load_channels(self.streamer_input.currentText())
# Do the first configuration, if the application was run for the first time
self.do_init_config()
# Finally show the window and the system tray icon, if it should be shown
self.show()
self.close_override = False
self.show_hide_systray()
self.check_and_do_database_migration()
def do_init_config(self):
do_config = self.config.get_config_value("is-configured")
if do_config == 0:
self.menu_cmd_configure()
self.config.set_config_value("is-configured", 1)
self.insertText("Using config database version '{}'".format(self.config.get_config_value("db-version")))
def setup_systray(self):
if not self.config.get_config_value("enable-systray-icon"):
self.systray = None
return
self.systray = QSystemTrayIcon(self)
self.systray.activated.connect(self.systray_activated)
main_menu = QMenu(self)
quit_action = QAction("&Quit", self)
quit_action.triggered.connect(self.on_close_override)
main_menu.addAction(quit_action)
self.systray.setContextMenu(main_menu)
def systray_activated(self, reason):
if reason == QSystemTrayIcon.Trigger:
if self.isVisible():
self.hide()
else:
self.showNormal()
def check_and_do_database_migration(self):
current_version = self.config.get_config_value("db-version")
if self.config.is_migration_needed():
self.insertText("Detected pending config database upgrade to version '{}'. Awaiting user input...".format(DBVERSION))
message = "You are using an older version of the application config database.\n\nWould you like to upgrade the database now? Your existing config database will be backed up."
upgrade_is_mandatory = current_version < MANDATORY_DBVERSION
if upgrade_is_mandatory:
message = message + "\n\nWARNING: Your config database is not compatible with this version of Livestreamer GUI. UPDATE IS MANDATORY! If you cancel the update, the application will exit."
reply = QMessageBox.question(self, "Pending config database upgrade", message, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
if reply == QMessageBox.Yes:
self.insertText("Backing up config database...")
backup = self.config.make_database_backup()
self.insertText("Current config database backed up to '{}'".format(backup))
self.insertText("Config database update initialized...")
self.update()
self.config.execute_migration()
new_version = self.config.get_config_value("db-version")
self.insertText("Config database update from version '{}' to '{}' finished.".format(current_version, new_version))
elif reply == QMessageBox.No and upgrade_is_mandatory:
QtCore.QTimer.singleShot(500, self.on_close_override)
# self.on_close_override() # Calling this in an __init__()-called method doesn't seem to work...
else:
self.insertText("Config database update cancelled. No changes were made.")
def setup_menu(self):
config_action = QAction("&Configure...", self)
config_action.triggered.connect(self.menu_cmd_configure)
quit_action = QAction("&Quit", self)
quit_action.setShortcut("Ctrl+Q")
quit_action.triggered.connect(self.on_close_override)
#.........这里部分代码省略.........
示例14: PymodoroGUI
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class PymodoroGUI(QWidget):
"""
GUI for Pymodoro
"""
def __init__(self):
"""
Initializer for the Pomodoro GUI class
"""
super(PymodoroGUI, self).__init__()
self.res_dir = os.path.join("../ext/")
self.green_tomato_icon = os.path.join(self.res_dir, "greentomato.png")
self.red_tomato_icon = os.path.join(self.res_dir, "redtomato.png")
self.tray = QSystemTrayIcon(QIcon(self.green_tomato_icon))
self.pom = Pomodoro()
self.pom.ringer.connect(self.signal)
self.init_ui()
def signal(self, pomodori):
"""
Callback given to the Pomodoro class.
Called when a pomodoro is up
"""
if pomodori % 4 == 0 and pomodori != 0:
self.tray.showMessage("4 Pomodori has passed!",
"Take a long break: 15-30min",
QSystemTrayIcon.Information)
else:
self.tray.showMessage("Pomodoro's up!",
"Take a short break: 3-5min",
QSystemTrayIcon.Information)
self.tray.setIcon(QIcon(self.green_tomato_icon))
def init_tray(self):
"""
Initializes the systray menu
"""
traymenu = QMenu("Menu")
self.tray.setContextMenu(traymenu)
self.tray.show()
self.tray.activated.connect(self.tray_click)
self.tray.setToolTip("Pomodori: "+str(self.pom.pomodori))
set_timer_tray = QLineEdit()
set_timer_tray.setPlaceholderText("Set timer")
set_timer_tray.textChanged.connect(lambda:
self.update_timer_text(set_timer_tray.text()))
traywidget = QWidgetAction(set_timer_tray)
traywidget.setDefaultWidget(set_timer_tray)
traymenu.addAction(traywidget)
start_timer_action = QAction("&Start Timer", self)
start_timer_action.triggered.connect(self.start_timer_click)
traymenu.addAction(start_timer_action)
exit_action = QAction("&Exit", self)
exit_action.triggered.connect(QCoreApplication.instance().quit)
traymenu.addAction(exit_action)
def tray_click(self, activation):
"""
Method called when clicking the tray icon
"""
if activation == QSystemTrayIcon.Trigger:
if self.isVisible():
self.hide()
else:
self.show()
elif activation == QSystemTrayIcon.Context:
self._tray.show()
def close_event(self, event):
self._tray.showMessage("Running in system tray",
"""The program will keep running in the system tray.\n
To terminate the program choose exit from the context menu""",
QSystemTrayIcon.Information)
self.hide()
event.ignore()
def wheel_event(self, event):
if event.delta() > 0:
timervalue = int(self.settimertext.text())
timervalue = timervalue + 1
self.settimertext.setText(str(timervalue))
else:
timervalue = int(self.settimertext.text())
timervalue = timervalue - 1
self.settimertext.setText(str(timervalue))
def init_ui(self):
"""
Initializes the GUI
"""
self.init_tray()
resolution = QApplication.desktop().availableGeometry()
width = 150
height = 100
# place exactly in center of screen
self.setGeometry((resolution.width() / 2) - (width / 2),
#.........这里部分代码省略.........
示例15: MainWidget
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import show [as 别名]
class MainWidget(QTabWidget):
"""Custom main widget."""
def __init__(self, parent=None, *args, **kwargs):
"""Init class custom tab widget."""
super(MainWidget, self).__init__(parent=None, *args, **kwargs)
self.parent = parent
self.setTabBar(TabBar(self))
self.setMovable(False)
self.setTabsClosable(False)
self.setTabShape(QTabWidget.Triangular)
self.init_preview()
self.init_corner_menus()
self.init_tray()
self.addTab(TabSearch(self), "Search")
self.addTab(TabTool(self), "Tools")
self.addTab(TabHtml(self), "HTML")
self.addTab(TabSymbols(self), "Symbols")
self._recent_tab = TabRecent(self)
self.recentify = self._recent_tab.recentify # shortcut
self.addTab(self._recent_tab, "Recent")
self.widgets_to_tabs(self.json_to_widgets(UNICODEMOTICONS))
self.make_trayicon()
self.setMinimumSize(QDesktopWidget().screenGeometry().width() // 1.5,
QDesktopWidget().screenGeometry().height() // 1.5)
# self.showMaximized()
def init_preview(self):
self.previews, self.timer = [], QTimer(self)
self.fader, self.previous_pic = FaderWidget(self), None
self.timer.setSingleShot(True)
self.timer.timeout.connect(lambda: [_.close() for _ in self.previews])
self.taimer, self.preview = QTimer(self), QLabel("Preview")
self.taimer.setSingleShot(True)
self.taimer.timeout.connect(lambda: self.preview.hide())
font = self.preview.font()
font.setPixelSize(100)
self.preview.setFont(font)
self.preview.setDisabled(True)
self.preview.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
self.preview.setAttribute(Qt.WA_TranslucentBackground, True)
def init_corner_menus(self):
self.menu_1, self.menu_0 = QToolButton(self), QToolButton(self)
self.menu_1.setText(" ⚙ ")
self.menu_1.setToolTip("<b>Options, Extras")
self.menu_0.setText(" ? ")
self.menu_0.setToolTip("<b>Help, Info")
font = self.menu_1.font()
font.setBold(True)
self.menu_1.setFont(font)
self.menu_0.setFont(font)
self.menu_tool, self.menu_help = QMenu("Tools Extras"), QMenu("Help")
self.menu_tool.addAction(" Tools & Extras ").setDisabled(True)
self.menu_help.addAction(" Help & Info ").setDisabled(True)
self.menu_0.setMenu(self.menu_help)
self.menu_1.setMenu(self.menu_tool)
self.menu_tool.addAction("Explain Unicode", self.make_explain_unicode)
self.menu_tool.addAction("Alternate Case Clipboard",
self.alternate_clipboard)
self.menu_tool.addSeparator()
self.menu_tool.addAction("AutoCenter Window", self.center)
self.menu_tool.addAction("Set Icon", self.set_icon)
self.menu_tool.addAction( # force recreate desktop file
"Add Launcher to Desktop", lambda: set_desktop_launcher(
"unicodemoticon", AUTOSTART_DESKTOP_FILE, True))
self.menu_tool.addAction("Move to Mouse position",
self.move_to_mouse_position)
self.menu_tool.addSeparator()
self.menu_tool.addAction("Minimize", self.showMinimized)
self.menu_tool.addAction("Hide", self.hide)
self.menu_tool.addAction("Quit", exit)
self.menu_help.addAction("About Qt 5",
lambda: QMessageBox.aboutQt(None))
self.menu_help.addAction("About Unicodemoticon",
lambda: open_new_tab(__url__))
self.setCornerWidget(self.menu_1, 1)
self.setCornerWidget(self.menu_0, 0)
self.currentChanged.connect(self.make_tabs_previews)
self.currentChanged.connect(self.make_tabs_fade)
def init_tray(self):
self.tray, self.menu = QSystemTrayIcon(self), QMenu(__doc__)
self.menu.addAction(" Emoticons").setDisabled(True)
self.menu.setIcon(self.windowIcon())
self.menu.addSeparator()
self.menu.setProperty("emoji_menu", True)
list_of_labels = sorted(UNICODEMOTICONS.keys()) # menus
menus = [self.menu.addMenu(_.title()) for _ in list_of_labels]
self.menu.addSeparator()
log.debug("Building Emoticons SubMenus.")
for item, label in zip(menus, list_of_labels):
item.setStyleSheet("padding:0;margin:0;border:0;menu-scrollable:1")
font = item.font()
font.setPixelSize(20)
item.setFont(font)
self.build_submenu(UNICODEMOTICONS[label.lower()], item)
self.menu.addSeparator()
self.menu.addAction("Alternate Case Clipboard",
#.........这里部分代码省略.........