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


Python QSystemTrayIcon.showMessage方法代码示例

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


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

示例1: Tray

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [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: SystemTrayRemoto

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [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

示例3: StartQT4

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [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

示例4: sysBaloon

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [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

示例5: SingleApplication

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

#.........这里部分代码省略.........
            self._running = True
        else:
            self._running = False
            if not self._memory.create(1):
                raise RuntimeError(self._memory.errorString().toLocal8Bit().data())

    def is_running(self):
        return self._running
    
    def exec_(self):
        self._create_tray_icon()
        self._create_mod_manager()
        self._start_file_watcher()
        self._create_socket()
        Settings()
        
        return super(SingleApplication, self).exec_()
    def _create_mod_manager(self):
        self.manager = ModManager()
        self.manager.mod_game_info()
        self.manager.signals.message.connect(self.show_message_from_mod_manager)
        self.manager.signals.error.connect(self.show_error_from_mod_manager)
    
    def _create_socket(self):    
        self.socket = ConnectionManager()
        
        self.manager.signals.contact_server.connect(self.socket.send)
        
        self.socket.message.connect(self.show_message_from_socket)
        self.socket.error.connect(self.show_error_from_socket)
        
        
    @property
    def _watcher_file_name(self):
        return "d2mp.pid"
    
    def _start_file_watcher(self):
        self.watcher = QFileSystemWatcher()
        self.watcher_file_path =  join(abspath("."), self._watcher_file_name)
        log.DEBUG("creating watcher file: %s" %(self.watcher_file_path))
        write_to_file(self.watcher_file_path, "Delete this file to shutdown D2MP\n")
        self.watcher.addPath(abspath("."))
        self.watcher.directoryChanged.connect(self._watcher_changed_callback)
    
    def _watcher_changed_callback(self, val):
        if self._watcher_file_name not in os.listdir(val): 
            secs = 3
            self.show_message("Shutdown", "Watcher file was deleted. D2MP will shotdown in %d seconds." %(secs))
            sleep(secs)
            self.exit()
    
    def _create_tray_icon(self):
        self.tray = QSystemTrayIcon(self)
        self.tray.setToolTip("D2Moddin Manager")
        self.tray.setIcon(QIcon(SETTINGS['icon']))
        traymenu = QMenu()
        traymenu.addAction("Restart", self.restart)
        traymenu.addAction("Uninstall", self.uninstall)
        traymenu.addAction("Preferences", UIManager().open_preferences)
        traymenu.addAction("Show mod list", self.show_mod_list)
        traymenu.addSeparator()

        traymenu.addAction("Exit", self.exit)
    
        self.tray.setContextMenu(traymenu)
        self.tray.show()
    
    def restart(self):
        python = sys.executable
        args = set(sys.argv)
        args.add("restart")
        os.execl(python, python, *list(sys.argv))
        self.exit()
    
    def uninstall(self):
        ModManager().delete_mods()
#         ModManager().uninstall_d2mp()
        self.exit()
    
    def exit(self):
        # do some cleanup
        return super(SingleApplication, self).exit()
    
    def show_mod_list(self):
        self.show_message("Mod List", ModManager().mod_names_as_string())
    
    def show_message_from_socket(self, message):
        self.show_message("Server message", message)
        
    def show_error_from_socket(self, message):
        self.show_message("Server error", message, QSystemTrayIcon.Critical)
        
    def show_message_from_mod_manager(self, message):
        self.show_message("ModManager message", message)
        
    def show_error_from_mod_manager(self, message):
        self.show_message("ModManager error", message, QSystemTrayIcon.Critical)
        
    def show_message(self, title, message, icon = QSystemTrayIcon.Information):
        self.tray.showMessage(title, message, icon)
开发者ID:BloodyD,项目名称:D2ModdinPyClient,代码行数:104,代码来源:main.py

示例6: TrayController

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [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

示例7: PigeonFeather

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

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

    def saveConfig(self, config):
        """Save the recieved config back to the config file and update the
        local copy in the object

        Keyword arguments:
        config -- A dict. of config recieved from the configuration dialog
        """
        # Set the local config object and try and save it
        self.config.set('main', 'woeid', config['woeid'])
        self.config.set('units', 'temperature', config['temperature'])
        self.config.set('units', 'wind', config['wind'])
        self.config.set('units', 'pressure', config['pressure'])
        self.config.set('units', 'distance', config['distance'])

        # Update the Weoid in the get weather thread
        self.getWeatherThread.setWoeid(config['woeid'])

        # Try and save the config
        try:
            with open(self.USER_CONFIG, 'wb') as configfile:
                self.config.write(configfile)
        except IOError as ioe:
            self.showErrorMessage('Could not save configuration settings' + \
                'to disk')

    def showErrorMessage(self, message):
        """Show a error as a tray balloon message

        Keyword arguments:
        message -- Error message to display
        """
        self.trayIcon.showMessage('Application Error', message, \
            QSystemTrayIcon.Critical)

    def trayIconClicked(self, reason):
        """If the tray icon is left clicked, show/hide the weather dialog
        If this is called on a Darwin(mac) machine do not pop up.  This follows
        better mac convention

        Keyword arguments:
        reason -- A QSystemTrayIcon.ActivationReason enum
        """
        # If mac then ignore click
        if platform.system() == 'Darwin':
            return

        # Test for left click
        if reason == 3:
            if self.weatherDialog.isVisible():
                self.weatherDialog.hide()
            else:
                self.weatherDialog.show()

    def showWeatherDialog(self):
        """Show the weather report dialog"""
        self.weatherDialog.show()

    def showConfigureDialog(self):
        """Show the configure dialog"""
        self.configureDialog.show()

    def showAboutDialog(self):
        """Show the about pyqtweather dialog"""
        QMessageBox.about(None, 'About Pigeon Feather', 'Pigeon Feather\n \
开发者ID:billyrayvalentine,项目名称:python-pigeonfeather,代码行数:70,代码来源:PigeonFeather.py

示例8: SessionTesterWindow

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

    progress_bar_change = QtCore.pyqtSignal()
    session_end = QtCore.pyqtSignal()

    def __init__(self):
        QMainWindow.__init__(self)

        self.isStarted = False
        self.isPaused = True
        self.isRIP = False
        self.current_time = 0

        self.tray_icon = QSystemTrayIcon(QIcon("sessiontester/resources/trayicon.xpm"))
        self.tray_icon.activated.connect(self.maximize_window)
        self.tray_icon.show()
        self.session_end.connect(self.session_end_message)

        self.setupUi(self)
        self.sessionStartButton.clicked.connect(self.start_session)
        self.newSessionButton.clicked.connect(self.new_session)
        self.exportSessionButton.clicked.connect(self.export_session)
        self.settingsButton.clicked.connect(self.open_settings)

        self.progressBar.setTextVisible(True)
        self.progressBar.setFormat("Session progress")
        self.session_config = SessionConfig(os.path.join(os.path.expanduser('~'),'sessiontester','config.ini'))

    def start_session(self):
        self.session_time = self.__count_session_time(
            self.sessionTimeField.time().toString("hh:mm:ss"))
        if (self.isPaused is True) & (self.session_time > 0):
            self.isPaused = False
            self.sessionStartButton.setText("Pause session")
            self.session_time = self.__count_session_time(
                self.sessionTimeField.time().toString("hh:mm:ss"))
            self.progressBar.setMaximum(self.session_time)
            if self.isRIP is True:
                self.progressBar.setValue(0)
                self.current_time = 0
                self.isRIP = False
            self.progress_bar_change.connect(self.set_progress_bar)
            self.t = threading.Thread(target=self.set_progress)
            self.t.daemon = True
            self.t.start()
        else:
            self.sessionStartButton.setText("Start session")
            self.isPaused = True

    def new_session(self):
        self.progressBar.setValue(0)
        self.progressBar.setFormat("Session progress")
        self.sessionStartButton.setText("Start session")
        self.current_time = 0
        self.isPaused = True

    def export_session(self):
        export_session.export_session_to_html(self.textEdit.toPlainText(), self.session_config)

    def set_progress_bar(self):
        self.progressBar.setValue(self.current_time)
        self.progressBar.setFormat("Time left:" + str(
            datetime.timedelta(seconds=self.time_to_go)))

    def session_end_message(self):
        self.tray_icon.showMessage("Session is over!", "Session time is over")
        self.sessionStartButton.setText("Start session")
        self.progressBar.setFormat("Session is over!")
        self.isPaused = True
        self.isRIP = True

    def set_progress(self):
        while (self.current_time < self.session_time):
            if self.isPaused is False:
                time.sleep(1)
            else:
                break
            if self.isPaused is False:
                self.current_time = self.current_time + 1
                self.progress_bar_change.emit()
                self.time_to_go = self.session_time - self.current_time
        if self.current_time == self.session_time:
            self.session_end.emit()

    def __count_session_time(self, time_string):
        self.result_date = time_string.split(":")
        return (int(self.result_date[0])*3600) + (int(self.result_date[1])*60) + int(self.result_date[2])

    def maximize_window(self):
        if self.isHidden() is False:
            self.hide()
        elif self.isHidden() is True:
            self.show()

    def open_settings(self):
        self.settings = SettingsWindow(self)
        self.settings.show()
开发者ID:rodion-goritskov,项目名称:pysessiontester,代码行数:99,代码来源:main.py

示例9: select

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [as 别名]
def select():
    """select folder"""
    fileDialog = QFileDialog(d)
    fileDialog.setWindowTitle("Select Folder")
    folderPath = fileDialog.getExistingDirectory()
    # print folderPath
    fts.append("%s" % folderPath)
    confManager.setValue("common", "folders", fts)
    confManager.save()


ui.connBtn.connect(ui.connBtn, SIGNAL("clicked()"), lambda: connect(ui.connBtn))
ui.addFolderBtn.clicked.connect(select)

menu = QMenu(m)
es = menu.addAction("ShowConfig")
menu.connect(es, SIGNAL("triggered()"), d, SLOT("show()"))

menu.addSeparator()

ea = menu.addAction("&Exit")
menu.connect(ea, SIGNAL("triggered()"), app, SLOT("quit()"))

t.setContextMenu(menu)

t.show()
t.showMessage("UniFileSyncPop Message", "This is UniFileSyncUI!!")

sys.exit(app.exec_())
开发者ID:neilhhw,项目名称:BaiduYunPanPython,代码行数:31,代码来源:TestUI.py

示例10: MainWindow

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

#.........这里部分代码省略.........
        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
            bits = str(server.mac).split(':')
            machex = ''.join([struct.pack('B', (int(x, 16))) for x in bits])
            magic += machex * 16

            sock = socket(type=SOCK_DGRAM)
            if server.broadcast:
                sock.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
            sock.sendto(magic, ('<broadcast>', server.port))
            sock.close()

            self.trayIcon.showMessage("Wake on LAN", "Magic packet was sent to %s" % server.alias, msecs=3000)

    def close(self):
        QApplication.quit()
开发者ID:dmzkrsk,项目名称:wol-tray,代码行数:104,代码来源:run.py

示例11: Terminals

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [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.session = None
        self.model = None
        self.devices = {}
        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 begin_session(self, fio, access):
        if access in ['operator']:
            self.ui.cashier.setText(fio)
            self.session = (fio, access)
            return True
        return False

    def end_session(self, block=False):
        self.ui.cashier.setText(u'')
        self.session = None
        self.stop_mainloop(block)
        return True

    def on_mainloop_stopped(self):
        self.mainloop = None
        if self.session:
            self.start_mainloop()

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

    def stop_mainloop(self, block=False):
        if self.mainloop:
            try:
                self.mainloop.state.disconnect()
                self.mainloop.ready.disconnect()
                self.mainloop.notify.disconnect()
            except TypeError:
                print 'NOTE: mainloop signals disconnect'

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

            self.mainloop.stop(block)
        else:
            self.ready.emit(False)

    def reset_mainloop(self, devices):
        self.devices = devices
        if self.mainloop is None:
            self.start_mainloop()
        else:
            self.stop_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()
#.........这里部分代码省略.........
开发者ID:stdk,项目名称:stoppark_panel,代码行数:103,代码来源:terminals.py

示例12: Application

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [as 别名]
class Application(QApplication):
    def __init__(self, *args, **kwargs):
        super(Application, self).__init__(*args, **kwargs)

        self.application_path = dirname(__file__)

        self.settings = Settings()

        if Settings.config().debug:
            basicConfig(level=DEBUG)

        self.setQuitOnLastWindowClosed(Settings.config().debug)

        self.history = History(
            tray_notify=self.tray_notify
        )

        self.aboutToQuit.connect(self.settings.settings_save)

        self.create_actions()
        self.create_tray_icon()

    def create_actions(self):
        self.action_take_screenshot = QAction(
            'Take a screenshot',
            self,
            triggered=self.take_screenshot
        )
        self.action_quit = QAction(
            'Quit',
            self,
            triggered=qApp.quit
        )

    def create_tray_icon(self):
        self.menu_tray = QMenu()
        self.menu_tray.addAction(self.action_take_screenshot)
        self.menu_tray.addSeparator()
        self.menu_tray.addAction(self.action_quit)

        self.icon_tray = QSystemTrayIcon(
            QIcon(join(
                self.application_path,
                'icons/camera.png'
            ))
        )
        self.icon_tray.setContextMenu(self.menu_tray)
        self.icon_tray.activated.connect(self.tray_icon_activated)
        self.icon_tray.show()

    def tray_icon_activated(self, reason):
        if reason != QSystemTrayIcon.Trigger:
            return
        self.take_screenshot()

    def take_screenshot(self):
        self.selecter = SelectArea(
            doneSignal=self.history.start_new_upload
        )

    def tray_notify(self, message):
        self.icon_tray.showMessage(
            'Screenshot',
            message,
            QSystemTrayIcon.Information,
            3000
        )
开发者ID:alexey-grom,项目名称:qt-screenshoter,代码行数:69,代码来源:main.py

示例13: Main

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

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

        self.ui.config.setup(self.ui.terminals, self.ui.payments)

        self.tabs = [self.ui.terminals, self.ui.payments, self.ui.config]

        self.ui.terminals.ready.connect(self.ui.config.terminals_ready)

        self.left_terminals = []
        self.right_terminals = []

        self.ui.leftUp.clicked.connect(self.left_up)
        self.ui.leftDown.clicked.connect(self.left_down)
        self.ui.rightUp.clicked.connect(self.right_up)
        self.ui.rightDown.clicked.connect(self.right_down)

        self.end_session()

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

        self.session = None
        self.executor = self.setup_executor()
        self.executor.start()

        #self.setWindowFlags(Qt.CustomizeWindowHint)

    def localize(self):
        self.setWindowTitle(_('Stop-Park'))
        self.ui.tabs.setTabText(0, _('Terminals'))
        self.ui.tabs.setTabText(1, _('Payments'))
        self.ui.tabs.setTabText(2, _('Config'))

    def setup_payments(self, executor):
        self.ui.payments.tariff_update_requested.connect(executor.update_tariffs)
        executor.tariffs_updated.connect(self.ui.payments.update_tariffs)

        executor.new_payable.connect(self.ui.payments.handle_payable)
        self.ui.payments.payable_accepted.connect(lambda: self.ui.tabs.setCurrentIndex(1))

        self.ui.payments.display_requested.connect(executor.display)
        self.ui.payments.manual_ticket_inputted.connect(executor.handle_bar)
        self.ui.payments.notify_requested.connect(self.notifier.showMessage)

        self.ui.payments.payment_initiated.connect(executor.pay)
        executor.payment_processed.connect(self.ui.payments.handle_payment_processed)

    def setup_executor(self):
        executor = Executor()
        executor.notify.connect(lambda title, msg: self.notifier.showMessage(title, msg))

        self.setup_payments(executor)

        executor.new_operator.connect(self.handle_operator)
        executor.session_begin.connect(self.begin_session)
        executor.session_end.connect(self.end_session)

        executor.option_notification.connect(self.ui.config.set_option)
        self.ui.config.option_changed.connect(executor.set_option)

        self.ui.config.terminals_changed.connect(executor.notify_terminals)
        self.ui.config.terminals_update_requested.connect(executor.update_terminals)
        executor.terminals_notification.connect(self.update_terminals)

        return executor

    @staticmethod
    def disconnect_from_signal(signal, slot):
        try:
            signal.disconnect(slot)
            return True
        except TypeError:  # .disconnect raises TypeError when given signal is not connected
            return False

    def handle_operator(self, card):
        print 'operator', card
        if not self.disconnect_from_signal(self.executor.new_operator, self.handle_operator):
            return

        if self.session is None:
            login_dialog = LoginDialog(card, parent=self)
            if login_dialog.exec_() == QDialog.Accepted:
                self.executor.begin_session(card)
        elif self.session == card.sn or card.type == Card.ADMIN:
            login_dialog = LogoffDialog(card, self.executor)
            if login_dialog.exec_() == QDialog.Accepted:
                self.executor.end_session()
        self.executor.new_operator.connect(self.handle_operator)

    def begin_session(self, sn, fio, access):
        self.session = sn
        for tab_index, tab_widget in enumerate(self.tabs):
            self.ui.tabs.setTabEnabled(tab_index, tab_widget.begin_session(fio, access))
        if access in ['admin', 'operator']:
#.........这里部分代码省略.........
开发者ID:Virlena,项目名称:stoppark_panel,代码行数:103,代码来源:gui.py

示例14: KerberusSystray

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [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

示例15: Terminals

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import showMessage [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


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