diff options
author | Cristián Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2022-10-05 11:19:04 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-10-07 06:15:54 +0000 |
commit | f7855e44da80e172adc7eec5d92ebd7278677b30 (patch) | |
tree | ef477c9d7e5a72ba71f4b440790cd8eef3e98cb4 /examples/widgets/animation/easing/easing.py | |
parent | 59f16a52788476d7e48a3a39af67dcab21076953 (diff) |
examples: adapt widgets examples
Fixing issues related to deprecated methods, Enums,
and more.
Change-Id: I07be29601f0ad257f5fcfb0a5bc4891cb7f9648c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 23374ffc4215c2492d52a2d3b34c1dd7af61afb2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/widgets/animation/easing/easing.py')
-rw-r--r-- | examples/widgets/animation/easing/easing.py | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/examples/widgets/animation/easing/easing.py b/examples/widgets/animation/easing/easing.py index 6df69717c..a7aee6cb5 100644 --- a/examples/widgets/animation/easing/easing.py +++ b/examples/widgets/animation/easing/easing.py @@ -148,7 +148,7 @@ class Window(QWidget): self._anim = Animation(self._item, b'pos') self._anim.setEasingCurve(QEasingCurve.OutBounce) - self._ui.easingCurvePicker.setCurrentRow(int(QEasingCurve.OutBounce)) + self._ui.easingCurvePicker.setCurrentRow(0) self.start_animation() @@ -161,15 +161,8 @@ class Window(QWidget): brush = QBrush(gradient) - # The original C++ code uses undocumented calls to get the names of the - # different curve types. We do the Python equivalant (but without - # cheating) - curve_types = [(n, c) for n, c in QEasingCurve.__dict__.items() - if (isinstance(c, QEasingCurve.Type) - and c != QEasingCurve.Custom - and c != QEasingCurve.NCurveTypes - and c != QEasingCurve.TCBSpline)] - curve_types.sort(key=lambda ct: ct[1]) + curve_types = [(f"QEasingCurve.{e.name}", e) for e in QEasingCurve.Type if e.value <= 40] + with QPainter(pix) as painter: @@ -229,15 +222,15 @@ class Window(QWidget): self._anim.setEasingCurve(curve_type) self._anim.setCurrentTime(0) - is_elastic = (curve_type >= QEasingCurve.InElastic - and curve_type <= QEasingCurve.OutInElastic) - is_bounce = (curve_type >= QEasingCurve.InBounce - and curve_type <= QEasingCurve.OutInBounce) + is_elastic = (curve_type.value >= QEasingCurve.InElastic.value + and curve_type.value <= QEasingCurve.OutInElastic.value) + is_bounce = (curve_type.value >= QEasingCurve.InBounce.value + and curve_type.value <= QEasingCurve.OutInBounce.value) self._ui.periodSpinBox.setEnabled(is_elastic) self._ui.amplitudeSpinBox.setEnabled(is_elastic or is_bounce) - self._ui.overshootSpinBox.setEnabled(curve_type >= QEasingCurve.InBack - and curve_type <= QEasingCurve.OutInBack) + self._ui.overshootSpinBox.setEnabled(curve_type.value >= QEasingCurve.InBack.value + and curve_type.value <= QEasingCurve.OutInBack.value) def path_changed(self, index): self._anim.set_path_type(index) |