本文整理汇总了Python中PyQt4.QtCore.QTimeLine.setLoopCount方法的典型用法代码示例。如果您正苦于以下问题:Python QTimeLine.setLoopCount方法的具体用法?Python QTimeLine.setLoopCount怎么用?Python QTimeLine.setLoopCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTimeLine
的用法示例。
在下文中一共展示了QTimeLine.setLoopCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RotatingIcon
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setLoopCount [as 别名]
class RotatingIcon(QLabel):
def __init__(self,resource,parent=None,steps=20,width=15,height=15):
QLabel.__init__(self,parent)
self._resource=resource
self._steps=steps
self._width=width
self._height=height
self._progressTimeLine = QTimeLine(1000, self)
self._progressTimeLine.setFrameRange(0, self._steps)
self._progressTimeLine.setLoopCount(0)
self.connect(self._progressTimeLine, SIGNAL("frameChanged(int)"), self.setProgress)
self._renderPixmaps()
self.setProgress(0)
def _renderPixmaps(self):
self._pixmaps=[]
for i in range(self._steps+1):
angle = int(i * 360.0 / self._steps)
pixmap = QPixmap(self._resource)
# if problem with loading png
if pixmap.size().width()==0:
self._pixmaps=None
return
rotate_matrix = QMatrix()
rotate_matrix.rotate(angle)
pixmap_rotated = pixmap.transformed(rotate_matrix)
pixmap_moved = QPixmap(pixmap.size())
pixmap_moved.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap_moved)
painter.drawPixmap((pixmap_moved.width() - pixmap_rotated.width()) / 2.0, (pixmap_moved.height() - pixmap_rotated.height()) / 2.0, pixmap_rotated)
painter.end()
self._pixmaps+=[pixmap_moved.scaled(self._width, self._height)]
def setProgress(self, progress):
if self._pixmaps!=None:
self.setPixmap(self._pixmaps[progress])
def start(self):
self.setProgress(0)
self._progressTimeLine.start()
def stop(self):
self._progressTimeLine.stop()
示例2: ProgressDialog
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setLoopCount [as 别名]
class ProgressDialog(Ui_ProgressDialog, DialogBase):
def __init__(self, publisher, plugin, parentWidget=None):
DialogBase.__init__(self, parentWidget)
self.setupUi(self)
self.setObjectName("ProgressDialog")
self.viewButton_.setEnabled(False)
self._publisher = publisher
self._plugin = plugin
self._parent = parentWidget
self._cancelled = False
self._timeline = QTimeLine(1000*60, self)
self._timeline.setFrameRange(0, 2*60)
self._timeline.setLoopCount(0)
self.progressBar_.setRange(0, 60)
self.connect(self._timeline, QtCore.SIGNAL("frameChanged(int)"),
self.updateProgressBar)
self.outputGroupBox_ = QGroupBox("Script output", None)
self.outputTextEdit_ = QTextEdit()
self.outputTextEdit_.setTextInteractionFlags(Qt.TextSelectableByKeyboard
| Qt.TextSelectableByMouse)
self.outputTextEdit_.setReadOnly(True)
self.outputTextEdit_.setTabChangesFocus(True)
self.outputTextEdit_.setAcceptRichText(False)
groupBoxLayout = QVBoxLayout()
groupBoxLayout.setObjectName("groupBoxLayout")
groupBoxLayout.setMargin(0)
groupBoxLayout.addWidget(self.outputTextEdit_)
self.outputGroupBox_.setLayout(groupBoxLayout)
gridLayout = QGridLayout()
gridLayout.setSizeConstraint(gridLayout.SetFixedSize)
gridLayout.addWidget(self.progressLabel_, 0, 0, 1, 4)
gridLayout.addWidget(self.progressBar_, 1, 0, 1, 4)
gridLayout.addWidget(self.detailsCheckBox_, 2, 0)
hSpacer = QSpacerItem(250, 10, QSizePolicy.Expanding)
gridLayout.addItem(hSpacer, 2, 1)
gridLayout.addWidget(self.viewButton_, 2, 2)
gridLayout.addWidget(self.cancelButton_, 2, 3)
gridLayout.addWidget(self.outputGroupBox_, 3, 0, 1, 4)
self.setLayout(gridLayout)
self.outputGroupBox_.setVisible(False)
def updateProgressBar(self, frame):
self.progressBar_.setValue(self.progressBar_.value() + 1)
def on_detailsCheckBox__stateChanged(self, state):
self.outputGroupBox_.setVisible(Qt.Checked == state)
gridLayout = self.layout()
if Qt.Checked == state:
gridLayout.setSizeConstraint(gridLayout.SetMaximumSize)
self.setSizeGripEnabled(True)
else:
gridLayout.setSizeConstraint(gridLayout.SetFixedSize)
self.setSizeGripEnabled(False)
def on_cancelButton__clicked(self, released=True):
if not released:
return
if self._cancelled:
self.reject()
return
self.cancelButton_.setEnabled(False)
self.progressLabel_.setText("Cancelling...")
self._publisher.cancel()
self._cancelled = True
QTimer.singleShot(5*1000, self, QtCore.SLOT("_kill()"))
@QtCore.pyqtSignature("_kill()")
def _cancel(self):
self._parent.update()
self._publisher.cancel(True)
self.reject()
def updatePublisherOutput(self, data):
self.outputTextEdit_.append(data)
def publishComplete(self, exitCode, exitStatus):
self.progressBar_.setValue(self.progressBar_.maximum())
self._timeline.stop()
if self._cancelled:
self.reject()
self._cancelled = True
publishSuccess = (0 == exitCode and QProcess.NormalExit == exitStatus)
output_exists = self.__findOutput()
self.viewButton_.setEnabled(publishSuccess and \
output_exists)
if not publishSuccess:
self.progressLabel_.setText("Publishing failed, see script output"
" for more details")
else:
self.progressLabel_.setText("Publishing completed")
#.........这里部分代码省略.........