Files
PyQt6_LaTaniere/src/controllers/glow_animator.py
2026-03-19 09:31:36 +01:00

33 lines
1.1 KiB
Python

from PySide6.QtCore import QPropertyAnimation, QEasingCurve
from PySide6.QtWidgets import QGraphicsDropShadowEffect
from config.constants import Glow
class GlowAnimator:
# Gère l'effet de lueur pulsée sur un widget.
def __init__(self, widget):
self._widget = widget
self._effect = QGraphicsDropShadowEffect(widget)
self._effect.setBlurRadius(Glow.BLUR_BASE.value)
self._effect.setOffset(0, 0)
self._effect.setColor(Glow.COLOR.value)
self._anim = QPropertyAnimation(self._effect, b"blurRadius")
self._anim.setDuration(Glow.ANIM_DURATION.value)
self._anim.setStartValue(Glow.BLUR_BASE.value)
self._anim.setKeyValueAt(0.5, Glow.BLUR_PEAK.value)
self._anim.setEndValue(Glow.BLUR_BASE.value)
self._anim.setEasingCurve(QEasingCurve.InOutQuad)
self._anim.setLoopCount(-1)
def start(self) -> None:
self._widget.setGraphicsEffect(self._effect)
self._anim.start()
def stop(self) -> None:
self._anim.stop()
self._widget.setGraphicsEffect(None)