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


Python QSystemTrayIcon.isVisible方法代码示例

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


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

示例1: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isVisible [as 别名]

#.........这里部分代码省略.........

        self.tray.setContextMenu(self.trayMenu)
        self.restoreSettings()
        # host list
        self.ui.filter.textChanged.connect(self.setHostList)
        self.setHostList()

    def getCryptoKey(self, passphrase=None):
        try:
            return self.config.getPrivateKey(passphrase)
        except ValueError:
            passwordDialog = PasswordDialog()
            retCode = passwordDialog.exec_()
            if retCode == QtGui.QDialog.Accepted:
                return self.getCryptoKey(passwordDialog.getPassword())
            else:
                raise SystemError("Password required")

    def showSettings(self):
        settingsWidget = self.findChild(QWidget, "settings")
        if settingsWidget is None:
            self.settingsWidget = SettingsPage()
            self.settingsWidget.setObjectName("settings")
            self.tabWidget.insertTab(0, self.settingsWidget, QIcon(":/ico/settings.svg"), 'Settings')

        index = self.tabWidget.indexOf(self.settingsWidget)
        self.tabWidget.setCurrentIndex(index)

    def connectHostFromMenu(self, action):
        self.connectHost(unicode(action.text()))

    def connectHostFromTrayMenu(self, action):
        tabPage = self.connectHost(unicode(action.text()))
        if not self.isVisible():
            self.tabWidget.setDetached(True, tabPage)

    def trayActivated(self, reason):
        if reason != QSystemTrayIcon.Trigger:
            return
        if self.isVisible():
            self.hide()
        else:
            self.show()
            self.activateWindow()

    def changeTrayIconVisibility(self):
        if self.tray.isVisible():
            self.tray.hide()
            if not self.isVisible():
                self.show()
        else:
            self.tray.show()

    def refreshGroups(self):
        groupList = self.hosts.getGroupsList()
        for group in groupList:
            if group not in self.groups:
                # add new groups as visible
                self.groups[group] = True

        # remove not existing groups
        keysToDelete = set(self.groups.keys()) - set(groupList)
        for key in keysToDelete:
            self.groups.pop(key)

    def assignGroup(self):
开发者ID:szatanszmatan,项目名称:myrdp,代码行数:70,代码来源:mainwindow.py

示例2: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isVisible [as 别名]

#.........这里部分代码省略.........
					break
				else:
					continue

			exec('self.widgets[name] = %s(name, self.config, self)' % pluginClass)
		#	print(('loaded plugin', self.widgets[name]))

		self.addDockWidget(0x4, self.widgets[name])
		self.widgets[name].reload_()

	def delWidget(self, name):
		#print 'del', name, type(name), '\n', self.widgets
		self.removeDockWidget(self.widgets[name])
		self.widgets[name].deleteLater()
		self.widgets[name] = None
		del self.widgets[name]

	def createWidgets(self):
		self.widgets = {}
		for name in self.config.loadLinks():
			self.createSingleWidget(name)


	@pyqtSlot()
	def onExit(self):
		self.config.saveWindowSize(self.size())
		QApplication.exit();

	def closeEvent(self, event):
		self.config.saveWindowSize(self.size())
#	       	QApplication.exit()
		# tray is visible -> close to tray
		# else close app
		if self.trayIcon.isVisible():
			event.accept()
		else:
			QApplication.exit()
			return
		# if close-to-tray is set, do so
		if self.config.loadCloseToTray():
			event.accept()
		else:
			QApplication.exit()
			return;
		# save this state
		if	self.trayIcon.isVisible():	self.config.saveIsVisible(False)
		else:					self.config.saveIsVisible(True);
	@pyqtSlot()
	def reload_(self):
		for name in self.widgets:
			self.widgets[name].reload_()
		self.pBar.setValue(self.config.loadReloadInterval())
		self.reloadTimer.start(self.config.loadReloadInterval()*1000)

	@pyqtSlot()
	def onAutoloadStatus(self):
		self.pBar.setValue(self.pBar.value()-1)
#		print([idx for idx in self.widgets])

	def onStyleMenu(self, a):
		QApplication.setStyle(QStyleFactory.create(a.text()))
		self.setStyle(QStyleFactory.create(a.text()))
		self.config.saveStyle(a.text())

	def onReloadTime(self):
		ok = False
开发者ID:ThePsyjo,项目名称:PyWv,代码行数:70,代码来源:window.py

示例3: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import isVisible [as 别名]
class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        PyQt4.uic.loadUi('ui/pyrex.ui', self)

        # Icon:
        self.setWindowIcon(QIcon("res/rex_18.png"))

        # Tray Icon:
        self.trayIcon = QSystemTrayIcon(QIcon("res/rex_18.png"), self)
        trayMenu = QMenu()
        self.actionQuit = QAction("Quitter", trayMenu)
        self.actionQuit.triggered.connect(self.close)
        trayMenu.addAction(self.actionQuit)
        self.trayIcon.setContextMenu(trayMenu)
        #self.trayIcon.show()

        QObject.connect(self.trayIcon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.icon_activated)
 
        # Tabs:
        self.tabs = QTabWidget()
        QObject.connect(self.tabs, SIGNAL('currentChanged(int)'), self.change_tab)

        self.downloads = TabDownloads(self.tabs)
        self.search = TabSearch(None, self.downloads, self.tabs)
        self.adv_search = TabAdvSearch(self.search, self.tabs)
        self.peers = TabPeers(self.search, self.downloads, self.tabs)
        self.options = TabOptions(self.tabs)
        self.shares = TabShares(self.tabs)
        self.informations = TabInformations(self.tabs)

        self.tabs.insertTab(0, self.search, u"Recherches")
        self.tabs.insertTab(1, self.adv_search, u"Recherche avancée")
        self.tabs.insertTab(2, self.downloads, u"Téléchargements")
        self.tabs.insertTab(3, self.peers, u"Utilisateurs")
        self.tabs.insertTab(4, self.options, u'Options')
        self.tabs.insertTab(5, self.shares, u'Mes partages')
        self.tabs.insertTab(6, self.informations, u'Informations')
        
        self.setCentralWidget(self.tabs)

    def change_tab(self, tab):
        if tab == 3:
            self.peers.update_peers()
        elif tab == 4:
            self.options.update_conf()
        elif tab == 5:
            self.shares.update_sharedirs()
        elif tab == 6:
            self.informations.update_informations()

    def closeEvent(self, event):
        if not self.trayIcon.isVisible() and Configuration.icon:
            self.trayIcon.show()
            self.hide()
            event.ignore()
        else:
            termine = True
            # On vérifie que tous les téléchargements soient finis
            for download in self.downloads.instance.downloads:
                if download.state == 3:
                    termine = False
            # Si il y a un download en cours on affiche la fenêtre
            if not termine and not Configuration.close_window:
                # Un petit messageBox avec bouton clickable :)
                msgBox = QMessageBox(QMessageBox.Question, u"Voulez-vous vraiment quitter?", u"Un ou plusieurs téléchargements sont en cours, et pyRex ne gère pas encore la reprise des téléchargements. Si vous quittez maintenant, toute progression sera perdue!")
                checkBox = QCheckBox(u"Ne plus afficher ce message", msgBox)
                checkBox.blockSignals(True)
                msgBox.addButton(checkBox, QMessageBox.ActionRole)
                msgBox.addButton("Annuler", QMessageBox.NoRole)
                yesButton = msgBox.addButton("Valider", QMessageBox.YesRole)
                msgBox.exec_()
                
                if msgBox.clickedButton() == yesButton:
                    # On save l'état du bouton à cliquer
                    if checkBox.checkState() == Qt.Checked:
                        Configuration.close_window = True
                        Configuration.write_config()
                    event.accept()
                else:
                    event.ignore()
            else:
                event.accept()
   
    def changeEvent(self, event):
        if event.type() == QEvent.WindowStateChange:
            if self.isMinimized():
                self.trayIcon.show()
                self.hide()
 
    def icon_activated(self, reason):
        if reason == QSystemTrayIcon.Trigger:
            if self.isVisible():
                self.hide()
            else:
                self.setWindowState(self.windowState() & ~Qt.WindowMinimized | Qt.WindowActive)
                self.activateWindow()
                self.show()
                self.trayIcon.hide()
开发者ID:MaximeCheramy,项目名称:pyrex,代码行数:102,代码来源:MainWindow.py


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