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


Python QSystemTrayIcon.show方法代码示例

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


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

示例1: Tray

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
class Tray(QObject):
    activated = pyqtSignal()

    def __init__(self, parent, title, icon):
        QObject.__init__(self)

        # Setup contextual menu
        if kde:
            self.menu = KMenu(parent)
            self.tray = KStatusNotifierItem(parent)
            self.tray.setStatus(KStatusNotifierItem.Passive)
            self.tray.setCategory(KStatusNotifierItem.ApplicationStatus)
            self.tray.setAssociatedWidget(parent)
            self.tray.setStandardActionsEnabled(False)
            self.tray.activateRequested.connect(self._activateRequested)
        else:
            self.menu = QMenu()
            self.tray = QSystemTrayIcon()
            self.tray.activated.connect(self._activated)
        self.setIcon(icon)
        self.setTitle(title)
        if not kde:
            self.tray.show()
        self.tray.setContextMenu(self.menu)

    def setActive(self, active=True):
        if kde:
            self.tray.setStatus(KStatusNotifierItem.Active if active else KStatusNotifierItem.Passive)

    def setTitle(self, title):
        if kde:
            self.tray.setTitle(title)
            self.tray.setToolTipTitle(title)
        else:
            self.tray.setToolTip(title)
        self.menu.setTitle(title)

    def setToolTipSubTitle(self, subtitle):
        if kde:
            self.tray.setToolTipSubTitle(subtitle)

    def setIcon(self, icon):
        if kde:
            self.tray.setIconByPixmap(icon)
            self.tray.setToolTipIconByPixmap(icon)
        else:
            self.tray.setIcon(icon)

    def showMessage(self, title, message, icon=None):
        if kde:
            self.tray.showMessage(title, message, "network-server")
        else:
            self.tray.showMessage(title, message, QSystemTrayIcon.Information if icon is None else icon)

    def _activated(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            self.activated.emit()

    def _activateRequested(self, active, pos):
        self.activated.emit()
开发者ID:herlang,项目名称:iosshy,代码行数:62,代码来源:tray.py

示例2: show

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
def show(main_window):
    """Show a system tray icon with a small icon."""
    _fix_unity_systray()
    icon = QIcon(multiplatform.get_path("encuentro/logos/icon-192.png"))
    sti = QSystemTrayIcon(icon, main_window)
    if not sti.isSystemTrayAvailable():
        logger.warning("System tray not available.")
        return

    def showhide(_):
        """Show or hide the main window."""
        if main_window.isVisible():
            main_window.hide()
        else:
            main_window.show()

    _menu = QMenu(main_window)
    _act = _menu.addAction("Mostrar/Ocultar")
    _act.triggered.connect(showhide)
    _act = _menu.addAction("Acerca de")
    _act.triggered.connect(main_window.open_about_dialog)
    _act = _menu.addAction("Salir")
    _act.triggered.connect(main_window.on_close)
    sti.setContextMenu(_menu)
    sti.show()
开发者ID:Nicogue,项目名称:Encuentro,代码行数:27,代码来源:systray.py

示例3: SystemTrayRemoto

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
class SystemTrayRemoto(ServicoFuncao):
    def __init__(self, parent=None):
        super().__init__(5433, 5433, parent)
        
        self.systemTray = QSystemTrayIcon()
        self.systemTray.setIcon(QIcon("bad.svg"))
        self.systemTray.show()
    
    @send_funcao
    def ativar(self, titulo, mensagem):
        self.systemTray.showMessage(titulo, mensagem, QSystemTrayIcon.Information, 3000)
开发者ID:tassio,项目名称:NetworkService,代码行数:13,代码来源:ativarSystemTray.py

示例4: Tray

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

    def __init__(self, parent):
        
        icon = AppIcon.getAppIcon()
        if icon:
            self.tray = QSystemTrayIcon(icon)
        else:
            self.tray = QSystemTrayIcon()
        self.parent = parent
        
        self.tray.setToolTip("Droid Navi")
        
        # Menu
        self.menu = QMenu()
        self.menu.addAction("Show Connected List", partial(self.maximize))
        self.menu.addAction("Options", partial(self.parent.openSettings))
        self.menu.addAction("Exit", partial(self.parent.close))
        self.tray.setContextMenu(self.menu)
        
        # Connect handlers
        self.tray.activated.connect(self.activated)
    
    def getTray(self):
        return self.tray
     
    def display(self, show):
        ''' Toggle showing the tray '''
        
        if show:
            self.tray.show()
        else:
            self.tray.hide()
    
    @pyqtSlot()
    def maximize(self):
        ''' Show the main window and hide tray icon '''
        
        self.display(False)
        self.parent.maximizeFromTray()
    
    @pyqtSlot()
    def activated(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            self.maximize()
开发者ID:Kenishi,项目名称:DroidNavi,代码行数:47,代码来源:tray.py

示例5: StartQT4

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
class StartQT4(Windows):
	
	def keyPressEvent(self, event):
		k = event.key() 
		if k == QtCore.Qt.Key_Escape:
			sys.exit()
		elif k == QtCore.Qt.Key_Enter-1:
			self.ui.btnSend.clicked.emit(True)
			
	def __init__(self, parent=None):
		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_winMain()
		self.ui.setupUi(self)
		QtCore.QObject.connect(self.ui.btnSend, QtCore.SIGNAL("clicked()"), self.SendQuery)
		self.setMouseTracking(True)
		self.setWindowFlags(QtCore.Qt.FramelessWindowHint|QtCore.Qt.WindowStaysOnTopHint| Qt.Popup | Qt.Tool)
		
		# 创建托盘
		self.icon = QIcon("img.png")
		self.trayIcon = QSystemTrayIcon(self)
		self.trayIcon.setIcon(self.icon)
		self.trayIcon.setToolTip(u"simple有道")
		self.trayIcon.show()
		# 托盘气泡消息
		self.trayIcon.showMessage(u"simple有道", u"simple有道已经启动,随时待命!")
		# 托盘菜单
		self.action = QAction(u"退出simple有道", self, triggered = sys.exit) # 触发点击后调用sys.exit()命令,即退出
		self.menu = QMenu(self)
		self.menu.addAction(self.action)
		self.trayIcon.setContextMenu(self.menu)
		self.move(1100,50)
		#开启监听线程
		system("xclip -f /dev/null")           #清空剪切板
		listener = Thread(target=listenMouse, args=(self.ui,))
		listener.setDaemon(True)
		listener.start()
        
	def SendQuery(self):
		querystring = "http://fanyi.youdao.com/openapi.do?keyfrom=hustbg&key=1205943053&type=data&doctype=json&version=1.1&q="+unicode(self.ui.txtSend.text())
		response = json.loads(requests.get(querystring).text)
		try:
			result = u"   音标:"+response["basic"].get("phonetic","")+u"\n   翻译:"+u','.join(response["translation"])+u"\n   解释:\n   "+'\n   '.join(response["basic"]["explains"][0:2])
			self.ui.labresult.setText(result)
		except:
			self.ui.labresult.setText(u"没有查到相关记录")
开发者ID:moonxue,项目名称:simpleyoudao,代码行数:47,代码来源:youdao.py

示例6: sysBaloon

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
class sysBaloon(QMainWindow):
    def baloon(self, t, m, tm=50000):
        self.trayicon = QSystemTrayIcon(self)
        if self.trayicon.supportsMessages():
            icona = QIcon('py.ico')
            self.trayicon.setIcon(icona)
            self.trayicon.show()
            self.trayicon.showMessage(t, m, msecs=tm)
            time.sleep(10)
            self.trayicon.hide()
        else:
            print "This Function isn't supported."
            choose = raw_input("Would you enable it? Y/N \n --> ")
            if choose == "Y":
                shell = os.popen('enable_baloon.reg')
                print "Run again this program"
            elif choose == "N":
                print "You don't use this program without baloon enabled."
            else:
                print "You have insert wrong char."
开发者ID:Mirio,项目名称:pywin_baloon,代码行数:22,代码来源:pywin_baloon.py

示例7: Example

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

    
def __init__(self):
super(Example, self).__init__()


self.path=sys.path[0]
f=open('%s/ACCESS_KEY'% self.path,'r')
f1=open('%s/ACCESS_SECRET'% self.path,'r')
f2=open('%s/user_info'% self.path)
self.user_name=f2.readline().strip('\n')
self.user_id=f2.readline().strip('\n')
self.a=f.readline().strip('\n')
self.b=f1.readline().strip('\n')
f.close()
f1.close()
f2.close()
self.initUI()

def initUI(self):

self.icon=QSystemTrayIcon()
self.icon.isSystemTrayAvailable()
self.icon.setIcon( QtGui.QIcon('%s/web.png'% self.path) )
self.icon.setToolTip ( 'dubbleclick to maximize')
self.icon.show()
self.icon.activated.connect(self.activate)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
                self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setGeometry(300, 300, 1500, 1000)
frame = QtGui.QFrame(parent=self)
                frame.setStyleSheet("QFrame {background: rgba(0,0,0,50%)}")
box=QtGui.QHBoxLayout()

self.edit = QtGui.QLineEdit()
         self.edit.setStyleSheet("background: rgba(0,0,0,100%); "" font-weight : bold;" "color: rgb(250,250,250);""border:5px solid ")
开发者ID:insidevivek,项目名称:PythonTwitterBot,代码行数:39,代码来源:fastertweet.py

示例8: __init__

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
    def __init__(self, parent=None):
        " Initialize QWidget inside MyMainWindow "
        super(MyMainWindow, self).__init__(parent)
        QWidget.__init__(self)
        self.statusBar().showMessage("               {}".format(__doc__))
        self.setStyleSheet("QStatusBar{color:grey;}")
        self.setWindowTitle(__doc__)
        self.setWindowIcon(QIcon.fromTheme("face-monkey"))
        self.setFont(QFont("Ubuntu Light", 10))
        self.setMaximumSize(QDesktopWidget().screenGeometry().width(), QDesktopWidget().screenGeometry().height())

        # directory auto completer
        self.completer = QCompleter(self)
        self.dirs = QDirModel(self)
        self.dirs.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot)
        self.completer.setModel(self.dirs)
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.completer.setCompletionMode(QCompleter.PopupCompletion)

        # Proxy support, by reading http_proxy os env variable
        proxy_url = QUrl(environ.get("http_proxy", ""))
        QNetworkProxy.setApplicationProxy(
            QNetworkProxy(
                QNetworkProxy.HttpProxy if str(proxy_url.scheme()).startswith("http") else QNetworkProxy.Socks5Proxy,
                proxy_url.host(),
                proxy_url.port(),
                proxy_url.userName(),
                proxy_url.password(),
            )
        ) if "http_proxy" in environ else None
        print((" INFO: Proxy Auto-Config as " + str(proxy_url)))

        # basic widgets layouts and set up
        self.mainwidget = QTabWidget()
        self.mainwidget.setToolTip(__doc__)
        self.mainwidget.setContextMenuPolicy(Qt.CustomContextMenu)
        self.mainwidget.tabCloseRequested.connect(lambda: self.mainwidget.setTabPosition(randint(0, 3)))
        # if self.mainwidget.tabPosition() == 0
        # else self.mainwidget.setTabPosition(0))
        self.mainwidget.setStyleSheet("QTabBar{color:white;font-weight:bold;}")
        self.mainwidget.setTabBar(TabBar(self))
        self.mainwidget.setMovable(True)
        self.mainwidget.setTabsClosable(True)
        self.mainwidget.setTabShape(QTabWidget.Triangular)
        self.setCentralWidget(self.mainwidget)
        self.dock1 = QDockWidget()
        self.dock2 = QDockWidget()
        self.dock3 = QDockWidget()
        for a in (self.dock1, self.dock2, self.dock3):
            a.setWindowModality(Qt.NonModal)
            a.setWindowOpacity(0.9)
            a.setWindowTitle(__doc__ if a.windowTitle() == "" else a.windowTitle())
            a.setStyleSheet(" QDockWidget::title{text-align:center;}")
            self.mainwidget.addTab(a, QIcon.fromTheme("face-smile"), "Double Click Me")

        # Paleta de colores para pintar transparente
        self.palette().setBrush(QPalette.Base, Qt.transparent)
        self.setPalette(self.palette())
        self.setAttribute(Qt.WA_OpaquePaintEvent, False)

        # toolbar and basic actions
        self.toolbar = QToolBar(self)
        self.toolbar.setIconSize(QSize(24, 24))
        # spacer widget for left
        self.left_spacer = QWidget(self)
        self.left_spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        # spacer widget for right
        self.right_spacer = QWidget(self)
        self.right_spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        qaqq = QAction(QIcon.fromTheme("application-exit"), "Quit", self)
        qaqq.setShortcut("Ctrl+Q")
        qaqq.triggered.connect(exit)
        qamin = QAction(QIcon.fromTheme("go-down"), "Minimize", self)
        qamin.triggered.connect(lambda: self.showMinimized())
        qamax = QAction(QIcon.fromTheme("go-up"), "Maximize", self)
        qanor = QAction(QIcon.fromTheme("view-fullscreen"), "AutoCenter AutoResize", self)
        qanor.triggered.connect(self.center)
        qatim = QAction(QIcon.fromTheme("mail-signed-verified"), "View Date and Time", self)
        qatim.triggered.connect(self.timedate)
        qabug = QAction(QIcon.fromTheme("help-about"), "Report a Problem", self)
        qabug.triggered.connect(
            lambda: qabug.setDisabled(True)
            if not call("xdg-open mailto:" + "[email protected]".decode("rot13"), shell=True)
            else " ERROR "
        )
        qamax.triggered.connect(lambda: self.showMaximized())
        qaqt = QAction(QIcon.fromTheme("help-about"), "About Qt", self)
        qaqt.triggered.connect(lambda: QMessageBox.aboutQt(self))
        qakde = QAction(QIcon.fromTheme("help-about"), "About KDE", self)
        if KDE:
            qakde.triggered.connect(KHelpMenu(self, "", False).aboutKDE)
        qaslf = QAction(QIcon.fromTheme("help-about"), "About Self", self)
        if KDE:
            qaslf.triggered.connect(KAboutApplicationDialog(aboutData, self).exec_)
        else:
            qaslf.triggered.connect(
                lambda: QMessageBox.about(
                    self.mainwidget,
                    __doc__,
                    "".join(
#.........这里部分代码省略.........
开发者ID:juancarlospaco,项目名称:pyqt_app_template,代码行数:103,代码来源:pyqt_app_template.py

示例9: __init__

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
    def __init__(self, parent=None):
        super(MainForm, self).__init__(parent)
        uic.loadUi("./MainWindow/form.ui", self)
        self.setWindowTitle("NFS-List")
        self.setLayout(self.gridLayout)
        self.setGeometry(100, 100, 640, 480)
        self.listWidget.setViewMode(QtGui.QListView.IconMode)
        self.listWidget.setMovement(QtGui.QListWidget.Static)
        self.ipv6_enable = True  # False
        self.addr_ipv4 = None
        self.addr_ipv6 = None
        self.addr_ipv4_array = []
        self.addr_ipv6_array = []
        self.time = 1

        self.hosts = []
        self.icon = QtGui.QIcon("./MainWindow/NAS-icon.png")
        self.setWindowIcon(self.icon)

        #Tray
        tray_menu = QtGui.QMenu(self)

        show_hide_action = QAction("Show/Hide", self)
        quitAction = QAction("Quit", self)

        tray_menu.addAction(show_hide_action)
        tray_menu.addAction(quitAction)

        tray = QSystemTrayIcon(self)
        tray.setIcon(self.icon)
        tray.setContextMenu(tray_menu)
        tray.setToolTip(self.windowTitle())
        tray.show()
        #
        show_hide_action.triggered.connect(self.showHideWindow)
        quitAction.triggered.connect(QtGui.qApp.quit)

        #end tray

        # self.ico.addPixmap(self.pixmap)
        ifaces = QtNetwork.QNetworkInterface.allInterfaces()
        for iface in ifaces:
            for addr_iface in iface.addressEntries():
                if addr_iface.ip() != QtNetwork.QHostAddress(QtNetwork.QHostAddress.LocalHost) and \
                                addr_iface.ip() != QtNetwork.QHostAddress(QtNetwork.QHostAddress.LocalHostIPv6):
                    if addr_iface.ip().toIPv4Address():
                        self.addr_ipv4_array.append(addr_iface)
                    if self.ipv6_enable:
                        if addr_iface.ip().toIPv6Address():
                            self.addr_ipv6_array.append(addr_iface)

        if len(self.addr_ipv4_array) >= 1:
            self.addr_ipv4 = self.addr_ipv4_array[0].ip().toString()

        #ip data#

        addr_mask = self.addr_ipv4_array[0].netmask().toString()
        #addr_mask = '255.255.255.192'

        __list_aprefix = addr_mask.split('.')
        cidr_ipv4 = 0
        bn = '0b'
        baddr = '0b'
        for i in __list_aprefix:
            cidr_ipv4 += rpclib.bit_count(int(i))
            bn += bin(int(i))[2:]

        print("cidr:", cidr_ipv4)
        print(bn)
        #
        total_ip_count = (2 ** (32 - cidr_ipv4)) - 2
        print('total_ip_count:', total_ip_count)
        print(self.addr_ipv4)
        int_net_ipv4 = rpclib.ip2int(self.addr_ipv4) & rpclib.ip2int(addr_mask)
        net_ipv4 = rpclib.int2ip(int_net_ipv4)


        #abc = ClockThread(self.time, self.add_new_item)
        #abc.start()
        #self.add_new_item('t34', 't32')

        self.scan_network = ThreadScanNetwork(10, net_ipv4, cidr_ipv4, self, 1.2)
        self.scan_network.start()

        self.check_host = ThreadCheckHost(self.hosts, self)
        self.check_host.start()

        #self.add_host({"host":"100.64.0.1","structures":[{'groups': [b'*'], 'dir': b'/srv/NFS'}]})
        """
        self.listWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

        self.actionInfo = QAction("Info", self.listWidget)
        self.actionMount = QAction("Mount", self.listWidget)
        self.listWidget.addAction(self.actionMount)
        self.listWidget.addAction(self.actionInfo)

        self.actionInfo.triggered.connect(self.showInfo)
        self.actionMount.triggered.connect(self.my_method)
        """
        self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
#.........这里部分代码省略.........
开发者ID:jershell,项目名称:nfs-list,代码行数:103,代码来源:__init__.py

示例10: ki18n

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
for author in AUTHORS:
    name, email = author.rsplit(" ", 1)
    aboutData.addAuthor(ki18n(name), ki18n(""), email.strip("<>"), "")

KCmdLineArgs.init (sys.argv, aboutData)
app = KApplication()

import smart
ctrl = smart.init()

mainWindow = KMainWindow()
smart_icon = QIcon(getPixmap("smart"))
mainWindow.setWindowIcon(smart_icon)
sysTray = QSystemTrayIcon(smart_icon, None)
smart_image = getPixmap("smart").toImage()
aboutData.setProgramLogo(QVariant(smart_image))

menu = QMenu(None)
menu.addAction(KIcon("view-refresh"), "Check for updates", smart_update)
menu.addAction(smart_icon, "Launch Smart", smart_gui)
menu.addSeparator()
menu.addAction(KIcon("help-about"), "About", show_about)
menu.addAction(KIcon("application-exit"), "Quit", exit_applet)
sysTray.setContextMenu(menu)

sysTray.show()

app.exec_()

# vim:ts=4:sw=4:et
开发者ID:blackPantherOS,项目名称:packagemanagement,代码行数:32,代码来源:ksmarttray.py

示例11: Terminals

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
class Terminals(QWidget):
    ready = pyqtSignal(bool)

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.ui = uic.loadUiType('terminal.ui')[0]()
        self.ui.setupUi(self)

        self.notifier = QSystemTrayIcon(QIcon('arrow-up-icon.png'), self)
        self.notifier.show()

        self.model = None
        self.mainloop = None
        self.delegate = None

    def test_display(self):
        if self.mainloop:
            self.mainloop.test_display()

    def update_device_config(self):
        if self.mainloop:
            self.mainloop.update_config()

    def terminal_open(self, addr):
        if self.mainloop:
            self.mainloop.terminal_open(addr)

    def terminal_close(self, addr):
        if self.mainloop:
            self.mainloop.terminal_close(addr)

    def start_mainloop(self):
        if self.mainloop is None:
            self.mainloop = Mainloop(parent=self)
            self.mainloop.ready.connect(self.on_mainloop_ready)
            self.mainloop.notify.connect(lambda title, msg: self.notifier.showMessage(title, msg))
            self.mainloop.start()

    def stop_mainloop(self):
        if self.mainloop:
            self.mainloop.state.disconnect()
            self.mainloop.ready.disconnect()
            self.mainloop.notify.disconnect()

            [self.ui.terminals.closePersistentEditor(self.model.index(row, 0))
             for row in xrange(self.model.rowCount())]
            self.mainloop.stop()

            self.mainloop = None

    def update_model(self):
        self.stop_mainloop()
        self.start_mainloop()

    def on_mainloop_ready(self, ok, titles):
        if ok:
            self.model = QStandardItemModel(len(titles), 1)
            [self.model.setItem(i, QStandardItem(str(addr))) for i, addr in enumerate(titles.keys())]

            self.delegate = TerminalDelegate(self.mainloop, titles)
            self.mainloop.report.connect(self.delegate.report)
            self.mainloop.state.connect(self.delegate.state)

            self.ui.terminals.setModel(self.model)
            self.ui.terminals.setItemDelegateForColumn(0, self.delegate)
            [self.ui.terminals.openPersistentEditor(self.model.index(row, 0))
             for row in xrange(self.model.rowCount())]

            self.mainloop.db.free_places_update.connect(self.ui.free_places.setValue)
            self.mainloop.update_config()
        else:
            self.model = None
            self.mainloop = None

        self.ready.emit(ok)
开发者ID:stdkFeanor,项目名称:stoppark_panel,代码行数:78,代码来源:terminals.py

示例12: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
class MainWindow(QMainWindow):
    groups = dict()
    typeQListWidgetHeader = 1000
    showHostsInGroups = False
    currentGroupName = None  # used to simple detect currently selected group to show menu

    def __init__(self):
        super(MainWindow, self).__init__()
        self.config = Config()
        self.db = Database(self.config.getConnectionString())

        cryptoKey = self.getCryptoKey()
        self.hosts = Hosts(self.db, cryptoKey)

        # menu used for each host
        self.hostMenu = QMenu()
        self.editAction = QAction(QIcon(':/ico/edit.svg'), "Edit", self.hostMenu)
        self.editAction.triggered.connect(self.editHost)
        self.hostMenu.addAction(self.editAction)

        # menu used for headers of groups
        self.groupsHeaderMenu = QMenu()
        self.editGroupAction = QAction(QIcon(':/ico/edit.svg'), "Edit group", self.groupsHeaderMenu)
        self.editGroupAction.triggered.connect(self.editGroup)
        self.deleteGroupAction = QAction(QIcon(':/ico/remove.svg'), "Delete group", self.groupsHeaderMenu)
        self.deleteGroupAction.triggered.connect(self.deleteGroup)
        self.groupsHeaderMenu.addAction(self.editGroupAction)
        self.groupsHeaderMenu.addAction(self.deleteGroupAction)

        self.duplicateAction = QAction(QIcon(':/ico/copy.svg'), "Duplicate", self.hostMenu)
        self.duplicateAction.triggered.connect(self.duplicateHost)
        self.hostMenu.addAction(self.duplicateAction)

        # todo: confirm for delete action
        self.deleteAction = QAction(QIcon(':/ico/remove.svg'), "Delete", self.hostMenu)
        self.deleteAction.triggered.connect(self.deleteHost)
        self.hostMenu.addAction(self.deleteAction)

        self.connectFramelessMenu = actions.generateScreenChoseMenu(self.hostMenu, self.connectFrameless,
                                                                    ':/ico/frameless.svg', "Connect frameless")
        self.hostMenu.addMenu(self.connectFramelessMenu)

        self.assignGroupAction = QAction("Assign group", self.hostMenu)
        self.assignGroupAction.triggered.connect(self.assignGroup)
        self.hostMenu.addAction(self.assignGroupAction)

        # setup main window
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # when top level changed, we changing dock title bar
        self.dockWidgetTileBar = DockWidgetTitleBar()
        self.ui.hostsDock.setTitleBarWidget(self.dockWidgetTileBar)
        self.ui.hostsDock.topLevelChanged.connect(self.dockLevelChanged)

        # set global menu
        self.globalMenu = QMenu()
        self.globalMenu.addAction(QIcon(':/ico/add.svg'), 'Add host', self.addHost)

        # groups menu
        self.groupsMenu = QMenu("Groups")
        self.groupsMenu.aboutToShow.connect(self.setGroupsMenu)
        self.globalMenu.addMenu(self.groupsMenu)

        # disable menu indicator
        self.ui.menu.setStyleSheet("QPushButton::menu-indicator {image: none;}")
        self.positionMenu = QMenu("Dock position")
        self.positionMenu.addAction("Left", lambda: self.setDockPosition(Qt.LeftDockWidgetArea))
        self.positionMenu.addAction("Right", lambda: self.setDockPosition(Qt.RightDockWidgetArea))
        self.positionMenu.addAction("Float", self.setDockFloat)
        self.globalMenu.addMenu(self.positionMenu)
        self.globalMenu.addAction('Change tray icon visibility', self.changeTrayIconVisibility)
        self.globalMenu.addAction('Settings', self.showSettings)
        self.globalMenu.addAction('Quit', self.close)
        self.ui.menu.setMenu(self.globalMenu)

        # set events on hosts list
        self.ui.hostsList.itemDoubleClicked.connect(self.slotConnectHost)
        self.ui.hostsList.itemClicked.connect(self.slotShowHost)
        self.ui.hostsList.customContextMenuRequested.connect(self.slotShowHostContextMenu)

        # set tab widget
        self.tabWidget = MyTabWidget()
        self.setCentralWidget(self.tabWidget)
        self.tabWidget.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tabWidget.customContextMenuRequested.connect(self.showCentralWidgetContextMenu)

        # set tray icon
        self.tray = QSystemTrayIcon(QIcon(":/ico/myrdp.svg"))
        self.tray.activated.connect(self.trayActivated)

        self.trayMenu = QMenu()
        self.trayMenu.addAction("Hide tray icon", self.changeTrayIconVisibility)
        self.connectHostMenuTray = ConnectHostMenu(self.hosts)
        self.connectHostMenuTray.triggered.connect(self.connectHostFromTrayMenu)
        self.trayMenu.addMenu(self.connectHostMenuTray)
        self.trayMenu.addAction("Quit", self.close)

        self.tray.setContextMenu(self.trayMenu)
        self.restoreSettings()
#.........这里部分代码省略.........
开发者ID:szatanszmatan,项目名称:myrdp,代码行数:103,代码来源:mainwindow.py

示例13: TrayController

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import show [as 别名]
class TrayController():
    """Display and control context menu."""

    setings_win = None

    def __init__(self):
        """Create TrayController."""
        self._tray_ico = QSystemTrayIcon()

    def set_menu(self, quit_callable, app_icon):
        """Show tray icon and sets its context menu items.

        :param quit_callable: function to call when user choose Exit menu item
        :type quit_callable: function
        :param app_icon: QIcon object - tray icon image
        :type app_icon: QIcon
        """
        tray_menu = QMenu()

        self._delay_menu = tray_menu.addAction(
            QIcon(
                os.path.join(PROGRAMM_RESOURCE_PATH, 'k-timer-icon.png')
            ),
            QtCore.QCoreApplication.translate('TrayController', 'Delay')
        )
        delay_sub_menu = QMenu()
        delay_sub_menu.addAction(
            QtCore.QCoreApplication.translate('TrayController', '15 minutes'),
            self.action_delay15
        )
        delay_sub_menu.addAction(
            QtCore.QCoreApplication.translate('TrayController', '30 minutes'),
            self.action_delay30
        )
        delay_sub_menu.addAction(
            QtCore.QCoreApplication.translate('TrayController', '1 hour'),
            self.action_delay60
        )
        delay_sub_menu.addAction(
            QtCore.QCoreApplication.translate('TrayController', '2 hours'),
            self.action_delay120
        )
        self._delay_menu.setMenu(delay_sub_menu)

        self._resume_menu = tray_menu.addAction(
            QIcon(
                os.path.join(PROGRAMM_RESOURCE_PATH,
                             'App-Quick-restart-icon.png')
            ),
            QtCore.QCoreApplication.translate('TrayController', 'Resume'),
            self.action_resume
        )
        self._resume_menu.setVisible(False)

        tray_menu.addAction(
            QIcon(
                os.path.join(PROGRAMM_RESOURCE_PATH, 'Settings-icon.png')
            ),
            QtCore.QCoreApplication.translate('TrayController', 'Settings'),
            self.show_settings
        )
        tray_menu.addSeparator()
        tray_menu.addAction(
            QIcon(
                os.path.join(PROGRAMM_RESOURCE_PATH, 'delete-icon.png')
            ),
            QtCore.QCoreApplication.translate('TrayController', 'Exit'),
            quit_callable
        )

        self._tray_ico.setContextMenu(tray_menu)
        self._tray_ico.setToolTip(PROGRAM_NAME)
        self._tray_ico.setIcon(app_icon)
        self._tray_ico.show()
        self.setings_win = SettingsManager(self, app_icon)

    def show_message(self, message):
        """Show message near tray icon.

        (alternative to show message is via module
        from PyQt4.QtGui import QMessageBox)

        :param message: message string
        :type message: str
        """
        self._tray_ico.showMessage(
            PROGRAM_NAME, message,
            msecs=5000
        )

    # Functions - menu click actions
    def toggle_delay_menu(self):
        """Toggle some context menu items.

        (depending program delay is on or off)
        """
        delay_on = self.setings_win.main_timer.delay_on
        self._resume_menu.setVisible(delay_on)
        self._delay_menu.setVisible(not delay_on)
        self.setings_win.ui.notActiveLb.setText(
#.........这里部分代码省略.........
开发者ID:pythonization,项目名称:reminder2standBy,代码行数:103,代码来源:tray.py

示例14: MainWindow

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

        self.settings = QSettings(QSettings.IniFormat, QSettings.UserScope, VENDOR, APP)

        self.setup = ConfigDialog(None, Qt.WindowSystemMenuHint | Qt.WindowTitleHint)
        self.setup.setModal(True)
        centerOnScreen(self.setup)
        self.setup.wake.connect(self.wake)
        self.setup.serversChanged.connect(self.updateMenu)

        self.menuServers = []

        self.trayIcon = QSystemTrayIcon(QIcon("res/power.png"), self)
        self.trayIcon.activated.connect(self.activated)

        menu = QMenu()

        self.populateMenuFromSettings(menu)

        menu.addSeparator()

        self.setupAction = menu.addAction(QIcon('res/setup.png'), "Configure")
        self.setupAction.triggered.connect(self.setup.show)

        menu.addSeparator()

        exitAction = menu.addAction("Exit")
        exitAction.triggered.connect(self.close)

        self.trayIcon.setContextMenu(menu)

        self.trayIcon.setToolTip("Wake on LAN")

        self.trayIcon.show()

        servers = self.settings.beginReadArray("servers")
        self.settings.endArray()

        if not servers:
            self.setup.show()

    def populateMenuFromSettings(self, menu):
        """
        :type menu: QMenu
        """
        actions = menu.actions()
        before = actions[0] if actions else None

        title = QWidgetAction(menu)
        label = QLabel("Hosts")
        font = label.font()
        px = font.pointSize()
        font.setBold(True)
        font.setPointSize(px * 1.5)
        label.setFont(font)
        label.setMargin(4)
        label.setIndent(10)
        #        label.setStyleSheet("font-weight: bold; margin: 4px 2px; border-bottom: 2px solid black")
        title.setDefaultWidget(label)

        menu.insertAction(before, title)
        self.menuServers.append(title)

        servers = self.settings.beginReadArray("servers")
        for d in range(servers):
            self.settings.setArrayIndex(d)
            server = Server.fromSettings(self.settings)
            action = QAction(QIcon("res/server.png"), server.alias, menu)
            menu.insertAction(before, action)
            action.setData(server)
            action.triggered.connect(self.wakeFromMenu)
            self.menuServers.append(action)
        self.settings.endArray()

    def activated(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            self.setup()
        elif reason == QSystemTrayIcon.Trigger:
            menu = QMenu()
            self.populateMenuFromSettings(menu)
            menu.exec_(QCursor.pos())

    def updateMenu(self):
        menu = self.trayIcon.contextMenu()
        for action in self.menuServers:
            action.setData(None)
            menu.removeAction(action)

        self.populateMenuFromSettings(menu)

    def wakeFromMenu(self):
        action = self.sender()
        server = action.data().toPyObject()
        self.wake(server)

    def wake(self, server):
        if QMessageBox.Yes == QMessageBox.question(self, "Wake on LAN", "Wake %s?" % server.alias, QMessageBox.Yes|QMessageBox.No):
            magic = '\xFF' * 6
#.........这里部分代码省略.........
开发者ID:dmzkrsk,项目名称:wol-tray,代码行数:103,代码来源:run.py

示例15: LunchinatorGuiController

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

#.........这里部分代码省略.........
            icon = QIcon(icon_file)
        
        self.statusicon.setIcon(icon)
        
    def createTrayIcon(self):
        if platform.linux_distribution()[0] == "Ubuntu":
            if not os.path.exists('/usr/share/icons/ubuntu-mono-light/status/24/lunchinator.svg') or \
               not os.path.exists('/usr/share/icons/ubuntu-mono-dark/status/24/lunchinator.svg'):
                result = QMessageBox.question(self.mainWindow,
                                              "Install Icons",
                                              "Do you want to install the Lunchinator icons into the Ubuntu theme folders? You will have to enter your sudo password.",
                                              buttons=QMessageBox.Yes | QMessageBox.No,
                                              defaultButton=QMessageBox.Yes)
                if result == QMessageBox.Yes:
                    if subprocess.call(['gksu', get_settings().get_resource('bin', 'install-lunch-icons.sh') + ' lunchinator']) == 0:
                        getCoreLogger().info("restarting after icons were installed")
                        restart(getCoreLogger())
                        return False
                    else:
                        QMessageBox.critical(self.mainWindow,
                                             "Error installing icons",
                                             "The icons were not installed, there was an error.",
                                             buttons=QMessageBox.Ok,
                                             defaultButton=QMessageBox.Ok)
                        getCoreLogger().info("icons were not installed because of an error")
        
        # initialize tray icon
        self.statusicon = QSystemTrayIcon(self.mainWindow)
        # _highlightIcon sets the default icon
        self._highlightIcon()
        contextMenu = self.init_menu(self.mainWindow)
        self.statusicon.activated.connect(self.trayActivated)
        self.statusicon.setContextMenu(contextMenu)
        self.statusicon.show()
        return True
        
    @loggingSlot(QSystemTrayIcon.ActivationReason)
    def trayActivated(self, reason):
        if getPlatform() == PLATFORM_MAC:
            # Trigger is sent even though the context menu is shown.
            return
        if reason == QSystemTrayIcon.Trigger:
            self.statusicon.contextMenu().popup(QCursor.pos())
        
    def _coldShutdown(self, exitCode=0):
        # before exiting, process remaining events (e.g., pending messages like HELO_LEAVE)
        QCoreApplication.processEvents()
        QCoreApplication.exit(exitCode)
        self._shuttingDown = True
        
    def isShuttingDown(self):
        return self._shuttingDown
        
    def quit(self, exitCode=0):
        if self.mainWindow is not None:
            self.mainWindow.close()
        if self.settingsWindow is not None:
            self.settingsWindow.close()
        
        if self.serverThread != None and not sip.isdeleted(self.serverThread) and self.serverThread.isRunning():
            self.serverThread.finished.disconnect(self.serverFinishedUnexpectedly)
            get_server().stop_server()
            getCoreLogger().info("Waiting maximal 30s for server to stop...")
            # wait maximal 30s 
            if self.serverThread.wait(30000):
                getCoreLogger().info("server stopped")
开发者ID:hannesrauhe,项目名称:lunchinator,代码行数:70,代码来源:gui_controller.py


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