Animation Framework
Платформа анимации призвана обеспечить простой способ создания анимированных и плавных графических интерфейсов. Анимируя свойства Qt, фреймворк предоставляет большую свободу для анимации виджетов и других объектов QObject. ...
Класс QPropertyAnimation анимирует свойства Qt.
Если использовать Python и PyQt, то, как вариант, может выглядеть примерно так:
import sys
from PyQt5.Qt import *
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.btn = QPushButton('click', self)
self.btn.setCheckable(True)
self.btn.resize(100, 100)
self.btn.move(125, 125)
self.btn.clicked.connect(self.btn_clicked)
def increase(self):
rect_start = QRect(self.btn.geometry())
rect_end = QRect(0, 0, 100, 100)
rect_end.moveCenter(rect_start.center())
animation = QPropertyAnimation(self.btn, b"geometry", self)
animation.setStartValue(rect_start)
animation.setEndValue(rect_end)
animation.setDuration(1000)
animation.start(QAbstractAnimation.DeleteWhenStopped)
def reduce(self):
rect_start = QRect(self.btn.geometry())
rect_end = QRect(0, 0, 50, 50)
rect_end.moveCenter(rect_start.center())
animation = QPropertyAnimation(self.btn, b"geometry", self)
animation.setStartValue(rect_start)
animation.setEndValue(rect_end)
animation.setDuration(1000)
animation.start(QAbstractAnimation.DeleteWhenStopped)
def btn_clicked(self, state):
if state:
self.reduce()
else:
self.increase()
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyle("Fusion")
w = MainWindow()
w.resize(400, 400)
w.show()
sys.exit(app.exec())

