• 并行动画组QParallelAnimationGroup


    动画组QParallelAnimationGroup继承于QAbstractAnimation

    QParallelAnimationGroup会同时执行添加到该组的所有动画

     1 import sys
     2 from PyQt5.QtGui import QPixmap
     3 from PyQt5.QtCore import QPropertyAnimation, QParallelAnimationGroup, QRect, QEasingCurve
     4 from PyQt5.QtWidgets import QApplication, QWidget, QLabel
     5 
     6 class Demo(QWidget):
     7     def __init__(self):
     8         super(Demo, self).__init__()
     9         self.resize(600, 600)
    10 
    11         self.plane = QLabel(self)
    12         self.plane.resize(50, 50)
    13         self.plane.setPixmap(QPixmap(r'D:ssssssimagesplane.png').scaled(self.plane.size()))
    14 
    15         self.plane2 = QLabel(self)
    16         self.plane2.resize(50, 50)
    17         self.plane2.setPixmap(QPixmap('D:ssssssimages飞机1.png').scaled(self.plane2.size()))
    18 
    19         self.animation1 = QPropertyAnimation(self.plane, b'geometry')
    20         self.animation1.setDuration(2000)
    21         self.animation1.setStartValue(QRect(200, 500, 50, 50))
    22         self.animation1.setEndValue(QRect(200, 100, 50, 50))
    23         self.animation1.setEasingCurve(QEasingCurve.OutCirc)
    24         self.animation1.setLoopCount(1)
    25 
    26         self.animation2 = QPropertyAnimation(self.plane2, b'geometry')
    27         self.animation2.setDuration(2000)
    28         self.animation2.setStartValue(QRect(300, 500, 50, 50))
    29         self.animation2.setEndValue(QRect(300, 100, 50, 50))
    30         self.animation2.setEasingCurve(QEasingCurve.OutCirc)
    31         self.animation2.setLoopCount(1)
    32 
    33         self.animation_group = QParallelAnimationGroup(self)  # 实例化一个并行动画
    34         self.animation_group.addAnimation(self.animation1)  #添加一个属性动画
    35         self.animation_group.addAnimation(self.animation2)
    36         self.animation_group.start()   #启动并行动画
    37 
    38 if __name__ == '__main__':
    39     app = QApplication(sys.argv)
    40     demo = Demo()
    41     demo.show()
    42     sys.exit(app.exec_())
  • 相关阅读:
    微信支付接口之心酸
    分页之辛酸史
    谈谈面试经历
    Linux(Ubuntu 14.0)
    Android(Xamarin)之旅(五)
    css:befor :after 伪元素的妙用
    js设计模式-代理模式
    html页面元素命名参考
    html5-meta标签和搜索引擎
    iframe框架加载完成后执行函数
  • 原文地址:https://www.cnblogs.com/liming19680104/p/10427632.html
Copyright © 2020-2023  润新知