| 52 | event.accept() |
| 53 | |
| 54 | def _initAnimate(self): |
| 55 | if hasattr(self, '_animate'): |
| 56 | return |
| 57 | self._width = self.minimumWidth() * 7 / 8 |
| 58 | self._height = self.minimumHeight() * 7 / 8 |
| 59 | # self._width=175 |
| 60 | # self._height=175 |
| 61 | wanimate = QPropertyAnimation(self, b'rWidth') |
| 62 | wanimate.setEasingCurve(QEasingCurve.OutElastic) |
| 63 | wanimate.setDuration(700) |
| 64 | wanimate.valueChanged.connect(self.update) |
| 65 | wanimate.setKeyValueAt(0, self._width) |
| 66 | # wanimate.setKeyValueAt(0.1, 180) |
| 67 | # wanimate.setKeyValueAt(0.2, 185) |
| 68 | # wanimate.setKeyValueAt(0.3, 190) |
| 69 | # wanimate.setKeyValueAt(0.4, 195) |
| 70 | wanimate.setKeyValueAt(0.5, self._width + 6) |
| 71 | # wanimate.setKeyValueAt(0.6, 195) |
| 72 | # wanimate.setKeyValueAt(0.7, 190) |
| 73 | # wanimate.setKeyValueAt(0.8, 185) |
| 74 | # wanimate.setKeyValueAt(0.9, 180) |
| 75 | wanimate.setKeyValueAt(1, self._width) |
| 76 | hanimate = QPropertyAnimation(self, b'rHeight') |
| 77 | hanimate.setEasingCurve(QEasingCurve.OutElastic) |
| 78 | hanimate.setDuration(700) |
| 79 | hanimate.setKeyValueAt(0, self._height) |
| 80 | # hanimate.setKeyValueAt(0.1, 170) |
| 81 | # hanimate.setKeyValueAt(0.3, 165) |
| 82 | hanimate.setKeyValueAt(0.5, self._height - 6) |
| 83 | # hanimate.setKeyValueAt(0.7, 165) |
| 84 | # hanimate.setKeyValueAt(0.9, 170) |
| 85 | hanimate.setKeyValueAt(1, self._height) |
| 86 | |
| 87 | self._animate = QParallelAnimationGroup(self) |
| 88 | self._animate.addAnimation(wanimate) |
| 89 | self._animate.addAnimation(hanimate) |
| 90 | |
| 91 | def enterEvent(self, event): |
| 92 | super(RubberBandButton, self).enterEvent(event) |