本文整理汇总了Python中PyQt4.QtCore.QTimeLine.resume方法的典型用法代码示例。如果您正苦于以下问题:Python QTimeLine.resume方法的具体用法?Python QTimeLine.resume怎么用?Python QTimeLine.resume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTimeLine
的用法示例。
在下文中一共展示了QTimeLine.resume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TimedProgressBar
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import resume [as 别名]
class TimedProgressBar(QProgressBar):
"""A QProgressBar showing a certain time elapse."""
hideOnTimeout = True
def __init__(self, parent=None):
super(TimedProgressBar, self).__init__(parent, minimum=0, maximum=100)
self._timeline = QTimeLine(updateInterval=100, frameChanged=self.setValue)
self._timeline.setFrameRange(0, 100)
self._hideTimer = QTimer(timeout=self._done, singleShot=True, interval=3000)
def start(self, total, elapsed=0.0):
"""Starts showing progress.
total is the number of seconds (maybe float) the timeline will last,
elapsed (defaulting to 0) is the value to start with.
"""
self._hideTimer.stop()
self._timeline.stop()
self._timeline.setDuration(total * 1000)
self._timeline.setCurrentTime(elapsed * 1000)
self.setValue(self._timeline.currentFrame())
self._timeline.resume()
if self.hideOnTimeout:
self.show()
def stop(self, showFinished=True):
"""Ends the progress display.
If showFinished is True (the default), 100% is shown for a few
seconds and then the progress is reset.
The progressbar is hidden if the hideOnTimeout attribute is True.
"""
self._hideTimer.stop()
self._timeline.stop()
if showFinished:
self.setValue(100)
self._hideTimer.start()
else:
self._done()
def _done(self):
if self.hideOnTimeout:
self.hide()
self.reset()