PyQt5 用动画效果不同速度的移动窗口 案例
import sys
from PyQt5.QtCore import Qt, QRect, QPropertyAnimation, QParallelAnimationGroup, QEasingCurve, QSequentialAnimationGroup
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QHBoxLayout, QPushButton, QMessageBox, QApplication, QVBoxLayout, QWidget, \
QLabel, QGridLayout, QLineEdit, QTextEdit, QFormLayout, QComboBox, QMainWindow
from CommonHelper import CommonHelper
'''
PyQt5 用动画效果不同速度的移动窗口 案例
'''
app = QApplication(sys.argv)
window1 = QMainWindow()
window1.show()
window2 = QMainWindow()
window2.show()
animation1 = QPropertyAnimation(window1,b'geometry')
animation2 = QPropertyAnimation(window2,b'geometry')
# group = QParallelAnimationGroup() # 并行,同时开始
group = QSequentialAnimationGroup() # 一个结束后另一个才开始
group.addAnimation(animation1)
group.addAnimation(animation2)
animation1.setDuration(3000)
animation1.setStartValue(QRect(0,0,100,30))
animation1.setEndValue(QRect(300,300,100,30))
animation1.setEasingCurve(QEasingCurve.OutBounce)
animation2.setDuration(4000)
animation2.setStartValue(QRect(300,200,100,30))
animation2.setEndValue(QRect(900,300,100,30))
animation2.setEasingCurve(QEasingCurve.OutBounce)
group.start()
sys.exit(app.exec())