本文整理匯總了Python中PyQt4.Qt.QPropertyAnimation.setLoopCount方法的典型用法代碼示例。如果您正苦於以下問題:Python QPropertyAnimation.setLoopCount方法的具體用法?Python QPropertyAnimation.setLoopCount怎麽用?Python QPropertyAnimation.setLoopCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.Qt.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.setLoopCount方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ThrobbingButton
# 需要導入模塊: from PyQt4.Qt import QPropertyAnimation [as 別名]
# 或者: from PyQt4.Qt.QPropertyAnimation import setLoopCount [as 別名]
class ThrobbingButton(QToolButton):
def __init__(self, *args):
QToolButton.__init__(self, *args)
self.animation = QPropertyAnimation(self, 'iconSize', self)
self.animation.setDuration(60/72.*1000)
self.animation.setLoopCount(4)
self.normal_icon_size = QSize(64, 64)
self.animation.valueChanged.connect(self.value_changed)
self.setCursor(Qt.PointingHandCursor)
self.animation.finished.connect(self.animation_finished)
def set_normal_icon_size(self, w, h):
self.normal_icon_size = QSize(w, h)
self.setIconSize(self.normal_icon_size)
try:
self.setMinimumSize(self.sizeHint())
except:
self.setMinimumSize(QSize(w+5, h+5))
def animation_finished(self):
self.setIconSize(self.normal_icon_size)
def enterEvent(self, ev):
self.start_animation()
def leaveEvent(self, ev):
self.stop_animation()
def value_changed(self, val):
self.update()
def start_animation(self):
if config['disable_animations']:
return
if self.animation.state() != self.animation.Stopped or not self.isVisible():
return
size = self.normal_icon_size.width()
smaller = int(0.7 * size)
self.animation.setStartValue(QSize(smaller, smaller))
self.animation.setEndValue(self.normal_icon_size)
QMetaObject.invokeMethod(self.animation, 'start', Qt.QueuedConnection)
def stop_animation(self):
self.animation.stop()
self.animation_finished()
示例2: Pointer
# 需要導入模塊: from PyQt4.Qt import QPropertyAnimation [as 別名]
# 或者: from PyQt4.Qt.QPropertyAnimation import setLoopCount [as 別名]
class Pointer(QWidget):
def __init__(self, gui):
QWidget.__init__(self, gui)
self.setObjectName('jobs_pointer')
self.setVisible(False)
self.resize(100, 80)
self.animation = QPropertyAnimation(self, "geometry", self)
self.animation.setDuration(750)
self.animation.setLoopCount(2)
self.animation.setEasingCurve(QEasingCurve.Linear)
self.animation.finished.connect(self.hide)
taily, heady = 0, 55
self.arrow_path = QPainterPath(QPointF(40, taily))
self.arrow_path.lineTo(40, heady)
self.arrow_path.lineTo(20, heady)
self.arrow_path.lineTo(50, self.height())
self.arrow_path.lineTo(80, heady)
self.arrow_path.lineTo(60, heady)
self.arrow_path.lineTo(60, taily)
self.arrow_path.closeSubpath()
c = self.palette().color(QPalette.Active, QPalette.WindowText)
self.color = QColor(c)
self.color.setAlpha(100)
self.brush = QBrush(self.color, Qt.SolidPattern)
# from PyQt4.Qt import QTimer
# QTimer.singleShot(1000, self.start)
@property
def gui(self):
return self.parent()
def point_at(self, frac):
return (self.path.pointAtPercent(frac).toPoint() -
QPoint(self.rect().center().x(), self.height()))
def rect_at(self, frac):
return QRect(self.point_at(frac), self.size())
def abspos(self, widget):
pos = widget.pos()
parent = widget.parent()
while parent is not self.gui:
pos += parent.pos()
parent = parent.parent()
return pos
def start(self):
if config['disable_animations']:
return
self.setVisible(True)
self.raise_()
end = self.abspos(self.gui.jobs_button)
end = QPointF( end.x() + self.gui.jobs_button.width()/3.0, end.y()+20)
start = QPointF(end.x(), end.y() - 0.5*self.height())
self.path = QPainterPath(QPointF(start))
self.path.lineTo(end)
self.path.closeSubpath()
self.animation.setStartValue(self.rect_at(0.0))
self.animation.setEndValue(self.rect_at(1.0))
self.animation.setDirection(self.animation.Backward)
num_keys = 100
for i in xrange(1, num_keys):
i /= num_keys
self.animation.setKeyValueAt(i, self.rect_at(i))
self.animation.start()
def paintEvent(self, ev):
p = QPainter(self)
p.setRenderHints(p.Antialiasing)
p.setBrush(self.brush)
p.setPen(Qt.NoPen)
p.drawPath(self.arrow_path)
p.end()