Skip to content

TextAnimation

Qt Base Class: QPropertyAnimation

Signature: QPropertyAnimation(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None QPropertyAnimation(self, target: PySide6.QtCore.QObject, propertyName: Union[PySide6.QtCore.QByteArray, bytes], parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
PropertyAnimation
prettyqt.core.propertyanimation

⋔ Inheritance diagram

graph TD
  1473293673600["animations.TextAnimation"]
  1473299825760["core.PropertyAnimation"]
  1473299835520["core.VariantAnimationMixin"]
  1473299791600["core.AbstractAnimationMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473289070624["QtCore.QPropertyAnimation"]
  1473289069648["QtCore.QVariantAnimation"]
  1473289055008["QtCore.QAbstractAnimation"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473299825760 --> 1473293673600
  1473299835520 --> 1473299825760
  1473299791600 --> 1473299835520
  1473299815024 --> 1473299791600
  140713234304496 --> 1473299815024
  1473289070624 --> 1473299825760
  1473289069648 --> 1473289070624
  1473289055008 --> 1473289069648
  1473288842240 --> 1473289055008
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: PropertyAnimation

Source code in prettyqt\animations\textanimation.py
class TextAnimation(core.PropertyAnimation):
    ID = "text"

    def __init__(
        self,
        start: datatypes.VariantType | None = None,
        end: datatypes.VariantType | None = None,
        duration: int = 1000,
        easing: core.easingcurve.TypeStr = "in_out_sine",
        fmt: NameStr = "html",
        mask: str = "{text}",
        parent: core.QObject | None = None,
    ):
        self._fmt = fmt
        self._mask = mask
        super().__init__(parent)
        self._child_anim = core.VariantAnimation()
        self._child_anim.valueChanged.connect(self.updateCurrentValue)
        self.set_easing(easing)
        self.set_duration(duration)
        if start is not None:
            self._child_anim.set_start_value(start)
        if end is not None:
            self._child_anim.set_end_value(end)
        self.setStartValue("")
        self.setStartValue("")

    def start(self, *args, **kwargs):
        self._child_anim.start(*args, **kwargs)
        super().start(*args, **kwargs)

    # TODO: also do stop etc.

    def set_start_value(self, value: datatypes.VariantType):
        self._child_anim.set_start_value(value)

    def set_end_value(self, value: datatypes.VariantType):
        self._child_anim.set_end_value(value)

    def set_easing(self, easing: core.easingcurve.TypeStr | core.QEasingCurve.Type):
        super().set_easing(easing)
        self._child_anim.set_easing(easing)

    def set_duration(self, duration: int):
        super().setDuration(duration)
        self._child_anim.set_duration(duration)

    def updateCurrentValue(self, value: datatypes.VariantType):
        match value:
            case None:
                return
            case gui.QColor():
                color = gui.Color(value)
                text = color.get_name(self._fmt) if self._fmt else color.toString()
                value = self._mask.format(text=text)
            case int() | float():
                value = self._mask.format(text=str(value))
            case core.QPoint() | core.QPointF():
                return f"{value.x()}, {value.y()}"
            case core.QSize() | core.QSizeF():
                return f"{value.width()}, {value.width()}"
        logger.debug(value)
        super().updateCurrentValue(value)

⌗ Property table

Qt Property Type Doc
objectName QString
state QAbstractAnimation::State
loopCount int
currentTime int
currentLoop int
direction QAbstractAnimation::Direction
duration int
startValue QVariant
endValue QVariant
currentValue QVariant
duration int
easingCurve QEasingCurve
propertyName QByteArray
targetObject QObject