Skip to content

AbstractAnimationMixin

Sub classes

Name Children Inherits
AbstractAnimation
prettyqt.core.abstractanimation
    VariantAnimationMixin
    prettyqt.core.variantanimation
    PauseAnimation
    prettyqt.core.pauseanimation
    Pause for QSequentialAnimationGroup.
      AnimationGroupMixin
      prettyqt.core.animationgroup

      Base classes

      Name Children Inherits
      ObjectMixin
      prettyqt.core.object

      â‹” Inheritance diagram

      graph TD
        565069530["core.AbstractAnimationMixin"]
        3227531497["core.ObjectMixin"]
        2751680898["builtins.object"]
        3227531497 --> 565069530
        2751680898 --> 3227531497

      🛈 DocStrings

      Bases: ObjectMixin

      The base of all animations.

      Source code in prettyqt/core/abstractanimation.py
      class AbstractAnimationMixin(core.ObjectMixin):
          """The base of all animations."""
      
          def __len__(self):
              return self.duration()
      
          def __and__(self, other: core.QAbstractAnimation) -> core.SequentialAnimationGroup:
              group = core.SequentialAnimationGroup()
              group.addAnimation(self)
              group.addAnimation(other)
              return group
      
          def __or__(self, other: core.QAbstractAnimation) -> core.ParallelAnimationGroup:
              group = core.ParallelAnimationGroup()
              group.addAnimation(self)
              group.addAnimation(other)
              return group
      
          def _get_map(self):
              maps = super()._get_map()
              maps |= {"direction": DIRECTION, "state": STATE}
              return maps
      
          def toggle_direction(self):
              direction = AbstractAnimation.Direction
              is_forward = self.direction() == direction.Forward
              direction = direction.Backward if is_forward else direction.Forward
              self.setDirection(direction)
      
          def set_direction(self, direction: DirectionStr | core.QAbstractAnimation.Direction):
              """Set animation direction.
      
              Args:
                  direction: animation direction
              """
              self.setDirection(DIRECTION.get_enum_value(direction))
      
          def get_direction(self) -> DirectionStr:
              """Get the current animation direction.
      
              Returns:
                  animation direction
              """
              return DIRECTION.inverse[self.direction()]
      
          def get_state(self) -> StateStr:
              """Get the current animation state.
      
              Returns:
                  animation state
              """
              return STATE.inverse[self.state()]
      
          def start_animation(
              self,
              policy: DeletionPolicyStr | core.QAbstractAnimation.DeletionPolicy = "keep",
              interval: int = 0,
              single_shot: bool = True,
          ):
              """Start the animation.
      
              Args:
                  policy: animation policy
                  interval: time interval / delay for timer
                  single_shot: whether animation gets triggered once or in intervals
              """
              if policy in DELETION_POLICY:
                  policy = DELETION_POLICY[policy]
              if interval:
                  fn = functools.partial(self.start, policy)
                  self.start_callback_timer(fn, interval, single_shot=single_shot)
              else:
                  self.start(policy)
      
          def restart_animation(
              self,
              policy: DeletionPolicyStr | core.QAbstractAnimation.DeletionPolicy = "keep",
          ):
              """Restart the animation.
      
              Args:
                  policy: animation policy
              """
              self.stop()
              self.start_animation(policy)
      
          def run(self, delay: int = 0, single_shot: bool = True):
              self.start_callback_timer(self.start, delay, single_shot=single_shot)
      

      get_direction() -> DirectionStr

      Get the current animation direction.

      Source code in prettyqt/core/abstractanimation.py
      def get_direction(self) -> DirectionStr:
          """Get the current animation direction.
      
          Returns:
              animation direction
          """
          return DIRECTION.inverse[self.direction()]
      

      get_state() -> StateStr

      Get the current animation state.

      Source code in prettyqt/core/abstractanimation.py
      def get_state(self) -> StateStr:
          """Get the current animation state.
      
          Returns:
              animation state
          """
          return STATE.inverse[self.state()]
      

      restart_animation(policy: DeletionPolicyStr | core.QAbstractAnimation.DeletionPolicy = 'keep')

      Restart the animation.

      Parameters:

      Name Type Description Default
      policy DeletionPolicyStr | DeletionPolicy

      animation policy

      'keep'
      Source code in prettyqt/core/abstractanimation.py
      def restart_animation(
          self,
          policy: DeletionPolicyStr | core.QAbstractAnimation.DeletionPolicy = "keep",
      ):
          """Restart the animation.
      
          Args:
              policy: animation policy
          """
          self.stop()
          self.start_animation(policy)
      

      set_direction(direction: DirectionStr | core.QAbstractAnimation.Direction)

      Set animation direction.

      Parameters:

      Name Type Description Default
      direction DirectionStr | Direction

      animation direction

      required
      Source code in prettyqt/core/abstractanimation.py
      def set_direction(self, direction: DirectionStr | core.QAbstractAnimation.Direction):
          """Set animation direction.
      
          Args:
              direction: animation direction
          """
          self.setDirection(DIRECTION.get_enum_value(direction))
      

      start_animation(policy: DeletionPolicyStr | core.QAbstractAnimation.DeletionPolicy = 'keep', interval: int = 0, single_shot: bool = True)

      Start the animation.

      Parameters:

      Name Type Description Default
      policy DeletionPolicyStr | DeletionPolicy

      animation policy

      'keep'
      interval int

      time interval / delay for timer

      0
      single_shot bool

      whether animation gets triggered once or in intervals

      True
      Source code in prettyqt/core/abstractanimation.py
      def start_animation(
          self,
          policy: DeletionPolicyStr | core.QAbstractAnimation.DeletionPolicy = "keep",
          interval: int = 0,
          single_shot: bool = True,
      ):
          """Start the animation.
      
          Args:
              policy: animation policy
              interval: time interval / delay for timer
              single_shot: whether animation gets triggered once or in intervals
          """
          if policy in DELETION_POLICY:
              policy = DELETION_POLICY[policy]
          if interval:
              fn = functools.partial(self.start, policy)
              self.start_callback_timer(fn, interval, single_shot=single_shot)
          else:
              self.start(policy)
      

      :fa-brands-github: Show source on GitHub