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


Python QTimer.isActive方法代码示例

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


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

示例1: KSmartTray

# 需要导入模块: from qt import QTimer [as 别名]
# 或者: from qt.QTimer import isActive [as 别名]
class KSmartTray(QObject):

    class State:
         Waiting = 'StateWaiting'
         Updating = 'StateUpdating'
         Checking = 'StateChecking'
         Upgrading = 'StateUpgrading'
         RunningSmart = 'StateRunningSmart'

    def __init__(self):
        QObject.__init__(self)
        self.sysTray = KMySystemTray()
        self.sysTray.setPixmap(self.sysTray.loadIcon("ksmarttray"))
        self.sysTray.show()
    
        self.process = KProcIO()
    
        self.state = KSmartTray.State.Waiting
        self.lastKnownStatus = ""
    
        self.blinkFlag = False
        self.updateFailed = False
    
        self.checkTimer = QTimer()
        self.blinkTimer = QTimer()

        QObject.connect(self.checkTimer, SIGNAL("timeout()"), self.checkUpgrades)
        QObject.connect(self.process, SIGNAL("processExited(KProcess *)"),
                self.processDone)
    
        QObject.connect(self, PYSIGNAL("foundNewUpgrades()"), self.startBlinking)
        QObject.connect(self, PYSIGNAL("foundNoUpgrades()"), self.stopBlinking)
        QObject.connect(self.sysTray, PYSIGNAL("mouseEntered()"), self.stopBlinking)
        QObject.connect(self.blinkTimer, SIGNAL("timeout()"), self.toggleBlink)
    
        QObject.connect(self.sysTray.checkAction, SIGNAL("activated()"),
                self.manualCheckUpgrades)
        QObject.connect(self.sysTray.startSmartAction, SIGNAL("activated()"),
                self.startSmart)
        QObject.connect(self.sysTray.stopAction, SIGNAL("activated()"),
                self.stopChecking)
        QObject.connect(self.sysTray, SIGNAL("quitSelected()"),
                KApplication.kApplication(), SLOT("quit()"))
    
        QObject.connect(self.sysTray, PYSIGNAL("activated()"), self.runUpgrades)
    
        self.checkTimer.start(5*60*1000)
    
        self.checkUpgrades()
    
    def internalCheckUpgrades(self, manual):
        if not manual and self.blinkTimer.isActive():
            return
        if self.state == KSmartTray.State.Waiting:
            self.sysTray.checkAction.setEnabled(False)
            self.sysTray.startSmartAction.setEnabled(False)
            self.sysTray.stopAction.setEnabled(True)
            self.process.resetAll()
            if manual:
                self.process.setArguments(["smart-update"])
            else:
                self.process.setArguments(["smart-update", "--after", "60"])
            if not self.process.start():
                KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                     "Couldn't run 'smart-update'.")
            else:
                QToolTip.add(self.sysTray, "Updating channels...")
                self.state = KSmartTray.State.Updating
    
    def checkUpgrades(self):
        self.internalCheckUpgrades(False)
    
    def manualCheckUpgrades(self):
        self.internalCheckUpgrades(True)
    
    def runUpgrades(self):
        if self.state != KSmartTray.State.Waiting:
            KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                 "There is a running process.")
        else:
            self.sysTray.checkAction.setEnabled(False)
            self.sysTray.startSmartAction.setEnabled(False)
            self.sysTray.stopAction.setEnabled(False)
            self.process.resetAll()
            self.process.setArguments(["kdesu", "-d", "-c", "smart --gui upgrade"])
            if not self.process.start():
                KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                     "Couldn't run 'smart upgrade'.")
            else:
                self.state = KSmartTray.State.Upgrading
                QToolTip.remove(self.sysTray)
                QToolTip.add(self.sysTray, "Running Smart Package Manager...")
    
    def startSmart(self):
        if self.state != KSmartTray.State.Waiting:
            KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                 "There is a running process.")
        else:
            self.sysTray.checkAction.setEnabled(False)
            self.sysTray.startSmartAction.setEnabled(False)
#.........这里部分代码省略.........
开发者ID:blackPantherOS,项目名称:packagemanagement,代码行数:103,代码来源:ksmarttray.py


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