并行动画组QParallelAnimationGroup

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:\ss\ssss\images\plane.png').scaled(self.plane.size()))
14 
15         self.plane2 = QLabel(self)
16         self.plane2.resize(50, 50)
17         self.plane2.setPixmap(QPixmap('D:\ss\ssss\images\飞机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_())

 

转载于:https://www.cnblogs.com/liming19680104/p/10427632.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值