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


Python QSystemTrayIcon.setVisible方法代码示例

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


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

示例1: WingedBox

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import setVisible [as 别名]
class WingedBox(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        self.setWindowTitle('WingedBox')
        pixmap = QPixmap(config.images['icon'])
        self.setWindowIcon(QIcon(pixmap))

        self.user = ''
        self.password = ''

        self._vbox = QVBoxLayout(self)
        self._login = Login(self, HOME_WINGED_PATH)
        self._vbox.addWidget(self._login)
        self._winged = Winged(self, pref)
        self._winged.setVisible(False)
        self._vbox.addWidget(self._winged)

        #SystemTray Menu
        self._menu = QMenu('WingedBox')
        self._myfiles = self._menu.addAction(QIcon(config.images['icon']), 'Files')
        self._myfiles.setEnabled(False)
        self._init = self._menu.addAction(self.style().standardIcon(QStyle.SP_DialogOkButton), 'Init Session')
        self._close = self._menu.addAction(self.style().standardIcon(QStyle.SP_DialogCloseButton), 'Close Session')
        self._close.setVisible(False)
        self._menu.addSeparator()
        self._properties = self._menu.addAction('Preferences')
        self._menu.addSeparator()
        exit = self._menu.addAction(self.style().standardIcon(QStyle.SP_TitleBarCloseButton), 'Exit')

        #SystemTray
        self._tray = QSystemTrayIcon(QIcon(pixmap), self)
        self._tray.setToolTip('WingedBox')
        self._tray.setVisible(True)
        self._tray.setContextMenu(self._menu)

        #Signal -> Slot
        self.connect(exit, SIGNAL("triggered()"), sys.exit)
        self.connect(self._myfiles, SIGNAL("triggered()"), self.show)
        self.connect(self._init, SIGNAL("triggered()"), self.show)
        self.connect(self._properties, SIGNAL("triggered()"), self.show_properties)
        self.connect(self._close, SIGNAL("triggered()"), self.disconnect)

    def show_properties(self):
        self.prop = preferences.Preferences(self, pref)
        self.prop.show()

    def disconnect(self):
        self.user = ''
        self.password = ''
        self._myfiles.setEnabled(False)
        self._init.setVisible(True)
        self._close.setVisible(False)
        self._winged.hide()
        self._login.show()

    def closeEvent(self, event):
        event.ignore()
        self.hide()
开发者ID:ifara,项目名称:wingedbox-client,代码行数:61,代码来源:wingedbox.py

示例2: KerberusSystray

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import setVisible [as 别名]
class KerberusSystray(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        icono = 'kerby-activo.ico'
        pixmap = QPixmap(icono)
        ##setear el nombre de la ventana
        self.setWindowTitle('Kerberus Control Parental')
        #colocar el icono cargado a la ventana
        self.setWindowIcon(QIcon(pixmap))
        ##creamos objeto Style para hacer uso de los iconos de Qt
	self.style = self.style()
        self.filtradoHabilitado = True

        if not os.path.isfile('dontShowMessage'):
            self.mostrarMensaje = True
            self.noMostrarMasMensaje()
        else:
            self.mostrarMensaje = False

        #Menu
        self.menu = QMenu('Kerberus')

        #accion deshabilitar filtrado
        self.deshabilitarFiltradoAction = self.menu.addAction(
                            self.style.standardIcon(QStyle.SP_DialogNoButton),
                            'Deshabilitar Filtrado'
                            )
        #accion habilitar filtrado
        self.habilitarFiltradoAction = self.menu.addAction(
                            self.style.standardIcon(QStyle.SP_DialogYesButton),
                            'Habilitar Filtrado'
                            )
        self.habilitarFiltradoAction.setVisible(False)
        #cambiar password
        self.cambiarPasswordAction = self.menu.addAction(
                self.style.standardIcon(QStyle.SP_BrowserReload),
                'Cambiar password de administrador'
                )
        #accion salir
        self.exitAction = self.menu.addAction(
                self.style.standardIcon(QStyle.SP_TitleBarCloseButton),
                'Salir')

        #SIGNAL->SLOT
        QObject.connect(
                self.exitAction,
                SIGNAL("triggered()"),
                lambda: sys.exit()
                )
        QObject.connect(
                self.menu, SIGNAL("clicked()"),
                lambda: self.menu.popup(QCursor.pos())
                )
        QObject.connect(
                self.deshabilitarFiltradoAction,
                SIGNAL("triggered()"),
                self.deshabilitarFiltradoWindow
                )
        QObject.connect(
                self.habilitarFiltradoAction,
                SIGNAL("triggered()"),
                self.habilitarFiltradoWindow
                )
        QObject.connect(
                self.cambiarPasswordAction,
                SIGNAL("triggered()"),
                self.cambiarPasswordWindow
                )

        #SystemTray
        #self.tray = QSystemTrayIcon(QIcon(pixmap), self)
        self.tray = QSystemTrayIcon(self.style.standardIcon(QStyle.SP_DialogYesButton), self)
        self.tray.setToolTip('Kerberus Control Parental - Activado')
        self.tray.setContextMenu(self.menu)
        self.tray.setVisible(True)



        QObject.connect(
                self.tray,
                SIGNAL("messageClicked()"),
                self.noMostrarMasMensaje
                )

        if self.mostrarMensaje:
            self.tray.showMessage(
                    u'Kerberus Control Parental',
                    u'Filtro de Protección para menores de edad Activado',
                    2000
                    )

    #def closeEvent(self, event):
        #event.ignore()
        #self.hide()

    def noMostrarMasMensaje(self):
        try:
            open('dontShowMessage','a').close()
        except IOError:
#.........这里部分代码省略.........
开发者ID:mboscovich,项目名称:Kerberus-Control-Parental,代码行数:103,代码来源:systemTray.py

示例3: MainWindow

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

#.........这里部分代码省略.........
    def findHostItemByName(self, name):
        result = self.ui.hostsList.findItems(name, Qt.MatchExactly)
        resultLen = len(result)
        if resultLen != 1:  # should be only one host
            logger.error("Host not found. Got %d results" % resultLen)
        return result[0]

    def showCentralWidgetContextMenu(self, pos):
        menu = QMenu()
        title = self.ui.hostsDock.windowTitle()

        hostsDockAction = menu.addAction(title)
        hostsDockAction.setCheckable(True)
        hostsDockAction.setChecked(self.ui.hostsDock.isVisible())
        hostsDockAction.triggered.connect(self.changeHostsDockWidgetVisibility)

        hostsDockAction = menu.addAction("Tray icon")
        hostsDockAction.setCheckable(True)
        hostsDockAction.setChecked(self.tray.isVisible())
        hostsDockAction.triggered.connect(self.changeTrayIconVisibility)

        connectHostMenuTray = ConnectHostMenu(self.hosts, "Connect")
        connectHostMenuTray.triggered.connect(self.connectHostFromMenu)
        menu.addMenu(connectHostMenuTray)

        menu.exec_(self.tabWidget.mapToGlobal(pos))

    def changeHostListView(self, checked):
        self.showHostsInGroups = checked
        self.setHostList()

    def changeHostsDockWidgetVisibility(self):
        isVisible = self.ui.hostsDock.isVisible()
        self.ui.hostsDock.setVisible(not isVisible)

    def isHostListHeader(self, item):
        if not item or item.type() == self.typeQListWidgetHeader:
            return True
        return False

    def slotShowHostContextMenu(self, pos):
        def changeMenusVisibility(isEnabled):
            self.connectFramelessMenu.setEnabled(isEnabled)
            self.editAction.setEnabled(isEnabled)
            self.duplicateAction.setEnabled(isEnabled)

        # ignore context menu for group headers
        item = self.ui.hostsList.itemAt(pos)

        if self.isHostListHeader(item):
            item = self.ui.hostsList.itemAt(pos)
            widgetItem = self.ui.hostsList.itemWidget(item)
            if widgetItem:
                self.currentGroupName = widgetItem.text()  # yea I'm so dirty
                if self.currentGroupName != unassignedGroupName:
                    self.groupsHeaderMenu.exec_(self.ui.hostsList.mapToGlobal(pos))
            return

        if len(self.ui.hostsList.selectedItems()) == 1:  # single menu
            changeMenusVisibility(True)
        else:
            changeMenusVisibility(False)

        self.hostMenu.exec_(self.ui.hostsList.mapToGlobal(pos))

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

示例4: QChatWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import setVisible [as 别名]
class QChatWindow(QMainWindow):
    newClientSignal = pyqtSignal(str)
    clientReadySignal = pyqtSignal(str)
    smpRequestSignal = pyqtSignal(int, str, str, int)
    handleErrorSignal = pyqtSignal(str, int)
    sendMessageToTabSignal = pyqtSignal(str, str, str)

    def __init__(self, restartCallback, connectionManager=None, messageQueue=None):
        QMainWindow.__init__(self)

        self.restartCallback = restartCallback
        self.connectionManager = connectionManager
        self.messageQueue = messageQueue
        self.newClientSignal.connect(self.newClientSlot)
        self.clientReadySignal.connect(self.clientReadySlot)
        self.smpRequestSignal.connect(self.smpRequestSlot)
        self.handleErrorSignal.connect(self.handleErrorSlot)
        self.sendMessageToTabSignal.connect(self.sendMessageToTab)

        self.chatTabs = QTabWidget(self)
        self.chatTabs.setTabsClosable(True)
        self.chatTabs.setMovable(True)
        self.chatTabs.tabCloseRequested.connect(self.closeTab)
        self.chatTabs.currentChanged.connect(self.tabChanged)

        self.statusBar = self.statusBar()
        self.systemTrayIcon = QSystemTrayIcon(self)
        self.systemTrayIcon.setVisible(True)

        self.__setMenubar()

        vbox = QVBoxLayout()
        vbox.addWidget(self.chatTabs)

        # Add the completeted layout to the window
        self.centralWidget = QWidget()
        self.centralWidget.setLayout(vbox)
        self.setCentralWidget(self.centralWidget)

        qtUtils.resizeWindow(self, 700, 400)
        qtUtils.centerWindow(self)

        # Title and icon
        self.setWindowTitle("Cryptully")
        self.setWindowIcon(QIcon(qtUtils.getAbsoluteImagePath('icon.png')))


    def connectedToServer(self):
        # Add an initial tab once connected to the server
        self.addNewTab()


    def newClient(self, nick):
        # This function is called from a bg thread. Send a signal to get on the UI thread
        self.newClientSignal.emit(nick)


    @pyqtSlot(str)
    def newClientSlot(self, nick):
        nick = str(nick)

        # Show a system notifcation of the new client if not the current window
        if not self.isActiveWindow():
            qtUtils.showDesktopNotification(self.systemTrayIcon, "Chat request from %s" % nick, '')

        # Show the accept dialog
        accept = QAcceptDialog.getAnswer(self, nick)

        if not accept:
            self.connectionManager.newClientRejected(nick)
            return

        # If nick already has a tab, reuse it
        if self.isNickInTabs(nick):
            self.getTabByNick(nick)[0].enable()
        else:
            self.addNewTab(nick)

        self.connectionManager.newClientAccepted(nick)


    def addNewTab(self, nick=None):
        newTab = QChatTab(self, nick)
        self.chatTabs.addTab(newTab, nick if nick is not None else "New Chat")
        self.chatTabs.setCurrentWidget(newTab)
        newTab.setFocus()


    def clientReady(self, nick):
        # Use a signal to call the client ready slot on the UI thread since
        # this function is called from a background thread
        self.clientReadySignal.emit(nick)


    @pyqtSlot(str)
    def clientReadySlot(self, nick):
        nick = str(nick)
        tab, tabIndex = self.getTabByNick(nick)
        self.chatTabs.setTabText(tabIndex, nick)
        tab.showNowChattingMessage()
#.........这里部分代码省略.........
开发者ID:juanrodriguezmonti,项目名称:Cryptully,代码行数:103,代码来源:qChatWindow.py

示例5: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import setVisible [as 别名]
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self._init_menu()
        self._init_actions()
        self._init_models()
        self.lt = ListenThread(self.add_new_device)
        self._install_akmods = False
        self._main_pko = PackageKitQt()

        # right frame
        self.comboBoxModules.currentIndexChanged.connect(self._handle_select_module)
        self.buttonBoxDetails.clicked.connect(self._handle_rbb)

        self.__debug_mode__ = True

        self.trayIcon = QSystemTrayIcon(self)
        self.trayIcon.setIcon(QIcon(":/img/gears"))
        self.trayIcon.activated.connect(self._handle_tray_icon_activate)
        self.hide()

    def closeEvent(self, event):
        event.ignore()
        self.hide()

    def _init_menu(self):
        self.actionFileExit.triggered.connect(self._handle_exit)

        self.listView.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.listViewActions.setContextMenuPolicy(Qt.ActionsContextMenu)

        # context menu for listView
        for act in self.menuDevices.actions():
            self.listView.addAction(act)
        # context menu for listViewActions
        for act in self.menuActions.actions():
            self.listViewActions.addAction(act)

    def _init_actions(self):
        self.actionDevicesDisable.triggered.connect(self._handle_disable_device)
        self.actionDevicesDisableAll.triggered.connect(self._handle_disable_all)
        self.actionActionsDelete.triggered.connect(self._handle_remove_current_action)
        self.actionActionsClear.triggered.connect(self._handle_clean_actions)
        self.actionActionsApply.triggered.connect(self._handle_apply_actions)

    def _init_models(self):
        self.model = DevicesListModel(self)
        self.listView.setModel(self.model)
        self.listView.selectionModel().currentChanged.connect(self._handle_select_item)

        self.act_model = ActionsModel(self)
        self.listViewActions.setModel(self.act_model)
        self.listViewActions.selectionModel().currentChanged.connect(self._handle_action_select_item)

        self.act_model.actionDeleted.connect(self.model.reset_changes)
        self.model.dataChanged.connect(self._handle_data_changed_in_model)

    def _init_pk(self):
        if self._main_pko is None:
            self._main_pko = PackageKitQt()

    def add_new_device(self, dev):
        self.model.add_new_device(dev)
        self.show_notification()

    def disen_device_notif(self, device_id, disable=False):
        if disable:
            self.lt.disable_device_notif(device_id)
        else:
            self.lt.enable_device_notif(device_id)

    def show_notification(self):
        # if self.isHidden():
        #    self.show()
        self.trayIcon.setVisible(True)

    def start_listen(self):
        self.lt.start()

    def _right_frame_apply(self, idx):
        d = self.model.device_by_index(idx)
        sel_cb_idx = self.comboBoxModules.currentIndex()
        sel_module = str(self.comboBoxModules.itemData(sel_cb_idx).toString())
        if sel_module == d.current_driver():
            return

        self.act_model.remove_actions_by_devid(d.device_id(), sel_module)
        pkgsi = d.packages_to_install(sel_module)
        pkgsr = d.packages_to_remove(sel_module)
        if len(pkgsi) > 0:
            self.act_model.add_new_action(d.device_id(), sel_module, pkgsi, 0)
        if len(pkgsr) > 0:
            rem_mds = str(", ").join(d.device_modules(sel_module))
            self.act_model.add_new_action(d.device_id(), rem_mds, pkgsr, 1)
        d.set_selected_driver(sel_module)
        self.set_right_frame(idx)

    def _current_device(self, idx=None):
        cur_idx = idx
#.........这里部分代码省略.........
开发者ID:elemc,项目名称:scod,代码行数:103,代码来源:MainWindow.py

示例6: KerberusSystray

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import setVisible [as 别名]
class KerberusSystray(QWidget):
    def __init__(self):
        self.chequeos_activos = True
        self.ultimo_estado_kerberus = True
        QWidget.__init__(self)
        #icono = 'kerby-activo.ico'
        #pixmap = QPixmap(icono)
        self.style = self.style()
        ##setear el nombre de la ventana
        self.setWindowTitle('Kerberus Control Parental')
        #colocar el icono cargado a la ventana
        self.setWindowIcon(self.style.standardIcon(
            QStyle.SP_DialogYesButton))

        self.filtradoHabilitado = True

        if not os.path.isfile('dontShowMessage'):
            self.mostrarMensaje = True
            self.noMostrarMasMensaje()
        else:
            self.mostrarMensaje = False

        #Menu
        self.menu = QMenu('Kerberus')

        #accion configurar Dominios
        self.configurarDominiosAction = self.menu.addAction(
                            'Permitir/Denegar dominios'
                            )
        #accion deshabilitar filtrado
        self.deshabilitarFiltradoAction = self.menu.addAction(
                            'Deshabilitar Filtrado'
                            )
        #accion habilitar filtrado
        self.habilitarFiltradoAction = self.menu.addAction(
                            'Habilitar Filtrado'
                            )
        self.habilitarFiltradoAction.setVisible(False)
        #cambiar password
        self.cambiarPasswordAction = self.menu.addAction(
                'Cambiar password de administrador'
                )
        #recordar password
        self.recordarPasswordAction = self.menu.addAction(
                'Recordar password del administrador'
                )

        #accion salir
        self.exitAction = self.menu.addAction(
                'Salir')

        #SIGNAL->SLOT
        QObject.connect(
                self.exitAction,
                SIGNAL("triggered()"),
                #lambda: sys.exit()
                self.salir
                )
        # esta conexion es utilizada para refrezcar el icono en caso de
        # que se desactive/active kerberus
        QObject.connect(
                self,
                SIGNAL("update()"),
                #lambda: sys.exit()
                self.setIconStatus
                )

        QObject.connect(
                self.menu, SIGNAL("clicked()"),
                lambda: self.menu.popup(QCursor.pos())
                )
        QObject.connect(
                self.deshabilitarFiltradoAction,
                SIGNAL("triggered()"),
                self.deshabilitarFiltradoWindow
                )
        QObject.connect(
                self.habilitarFiltradoAction,
                SIGNAL("triggered()"),
                self.habilitarFiltradoWindow
                )
        QObject.connect(
                self.cambiarPasswordAction,
                SIGNAL("triggered()"),
                self.cambiarPasswordWindow
                )
        QObject.connect(
                self.configurarDominiosAction,
                SIGNAL("triggered()"),
                self.configurarDominios
                )
        QObject.connect(
                self.recordarPasswordAction,
                SIGNAL("triggered()"),
                self.recordarPasswordWindow
                )
        
        #SystemTray
        #self.tray = QSystemTrayIcon(QIcon(pixmap), self)
        self.tray = QSystemTrayIcon(self.style.standardIcon(
#.........这里部分代码省略.........
开发者ID:mboscovich,项目名称:Kerberus-Control-Parental,代码行数:103,代码来源:systemTray.py


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