本文整理汇总了Python中PyQt4.QtCore.QPropertyAnimation.currentTime方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.currentTime方法的具体用法?Python QPropertyAnimation.currentTime怎么用?Python QPropertyAnimation.currentTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.currentTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExplodingAnimation
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import currentTime [as 别名]
class ExplodingAnimation(Animation):
def __init__(self, center, duration, parent = None):
super(ExplodingAnimation, self).__init__(parent)
self.center = center
self.__radius = 1.0
self.anim = QPropertyAnimation(self, "radius")
self.anim.setStartValue(1.0)
self.anim.setEndValue(100.0)
self.anim.setDuration(duration)
self.anim.setEasingCurve(QEasingCurve.OutExpo)
self.anim.valueChanged.connect(self.updated)
self.anim.finished.connect(self.finished)
def start(self):
self.anim.start()
def stop(self):
self.anim.stop()
def getRadius(self):
return self.__radius
def setRadius(self, r):
self.__radius = r
radius = pyqtProperty("qreal", getRadius, setRadius)
def paint(self, painter):
opacity = 1.0 - float(self.anim.currentTime()) / self.anim.duration()
pen = QPen(QColor(255, 0, 0, opacity * 255))
pen.setWidth(3)
painter.setPen(pen)
painter.setBrush(Qt.transparent)
rect = QRect(0, 0, self.radius * 2, self.radius * 2)
rect.moveCenter(self.center)
painter.drawEllipse(rect)