本文整理汇总了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)
#.........这里部分代码省略.........