MCPcopy
hub / github.com/PyQt5/PyQt / _initAnimate

Method _initAnimate

QPushButton/RubberBandButton.py:91–135  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

89 event.accept()
90
91 def _initAnimate(self):
92 if hasattr(self, "_animate"):
93 return
94 self._width = self.minimumWidth() * 7 / 8
95 self._height = self.minimumHeight() * 7 / 8
96 # self._width=175
97 # self._height=175
98
99 # 宽度动画
100 wanimate = QPropertyAnimation(self, b"rWidth")
101 wanimate.setEasingCurve(QEasingCurve.OutElastic)
102 wanimate.setDuration(700)
103 wanimate.valueChanged.connect(self.update)
104
105 # 插入宽度线性值
106 wanimate.setKeyValueAt(0, self._width)
107 # wanimate.setKeyValueAt(0.1, 180)
108 # wanimate.setKeyValueAt(0.2, 185)
109 # wanimate.setKeyValueAt(0.3, 190)
110 # wanimate.setKeyValueAt(0.4, 195)
111 wanimate.setKeyValueAt(0.5, self._width + 6)
112 # wanimate.setKeyValueAt(0.6, 195)
113 # wanimate.setKeyValueAt(0.7, 190)
114 # wanimate.setKeyValueAt(0.8, 185)
115 # wanimate.setKeyValueAt(0.9, 180)
116 wanimate.setKeyValueAt(1, self._width)
117
118 # 高度动画
119 hanimate = QPropertyAnimation(self, b"rHeight")
120 hanimate.setEasingCurve(QEasingCurve.OutElastic)
121 hanimate.setDuration(700)
122
123 # 插入高度线性值
124 hanimate.setKeyValueAt(0, self._height)
125 # hanimate.setKeyValueAt(0.1, 170)
126 # hanimate.setKeyValueAt(0.3, 165)
127 hanimate.setKeyValueAt(0.5, self._height - 6)
128 # hanimate.setKeyValueAt(0.7, 165)
129 # hanimate.setKeyValueAt(0.9, 170)
130 hanimate.setKeyValueAt(1, self._height)
131
132 # 设置动画组
133 self._animate = QParallelAnimationGroup(self)
134 self._animate.addAnimation(wanimate)
135 self._animate.addAnimation(hanimate)
136
137 def enterEvent(self, event):
138 super(RubberBandButton, self).enterEvent(event)

Callers 1

paintEventMethod · 0.95

Calls 1

setDurationMethod · 0.80

Tested by

no test coverage detected