Skip to content

statemachine

Class info

Classes

Name Children Inherits
AbstractState
prettyqt.statemachine.abstractstate
    AbstractStateMixin
    prettyqt.statemachine.abstractstate
    AbstractTransition
    prettyqt.statemachine.abstracttransition
      AbstractTransitionMixin
      prettyqt.statemachine.abstracttransition
      EventTransition
      prettyqt.statemachine.eventtransition
        FinalState
        prettyqt.statemachine.finalstate
          HistoryState
          prettyqt.statemachine.historystate
            KeyEventTransition
            prettyqt.statemachine.keyeventtransition
              MouseEventTransition
              prettyqt.statemachine.mouseeventtransition
                SignalTransition
                prettyqt.statemachine.signaltransition
                  State
                  prettyqt.statemachine.state
                    StateMachine
                    prettyqt.statemachine.statemachine
                      StateMixin
                      prettyqt.statemachine.state

                      🛈 DocStrings

                      Provides classes for creating and executing state graphs.

                      AbstractTransitionMixin

                      Bases: ObjectMixin, _AbstractTransitionBase

                      Source code in prettyqt/statemachine/abstracttransition.py
                      class AbstractTransitionMixin(core.ObjectMixin, _AbstractTransitionBase):
                          def _get_map(self):
                              maps = super()._get_map()
                              maps |= {"transitionType": TRANSITION_TYPE}
                              return maps
                      
                          def set_transition_type(
                              self, typ: TransitionTypeStr | QtStateMachine.QAbstractTransition.TransitionType
                          ):
                              """Set transition type.
                      
                              Args:
                                  typ: transition type to use
                              """
                              self.setTransitionType(TRANSITION_TYPE.get_enum_value(typ))
                      
                          def get_transition_type(self) -> TransitionTypeStr:
                              """Return current transition type.
                      
                              Returns:
                                  transition type
                              """
                              return TRANSITION_TYPE.inverse[self.transitionType()]
                      

                      get_transition_type() -> TransitionTypeStr

                      Return current transition type.

                      Source code in prettyqt/statemachine/abstracttransition.py
                      def get_transition_type(self) -> TransitionTypeStr:
                          """Return current transition type.
                      
                          Returns:
                              transition type
                          """
                          return TRANSITION_TYPE.inverse[self.transitionType()]
                      

                      set_transition_type(typ: TransitionTypeStr | QtStateMachine.QAbstractTransition.TransitionType)

                      Set transition type.

                      Parameters:

                      Name Type Description Default
                      typ TransitionTypeStr | TransitionType

                      transition type to use

                      required
                      Source code in prettyqt/statemachine/abstracttransition.py
                      def set_transition_type(
                          self, typ: TransitionTypeStr | QtStateMachine.QAbstractTransition.TransitionType
                      ):
                          """Set transition type.
                      
                          Args:
                              typ: transition type to use
                          """
                          self.setTransitionType(TRANSITION_TYPE.get_enum_value(typ))
                      

                      HistoryState

                      Bases: AbstractStateMixin, QHistoryState

                      Source code in prettyqt/statemachine/historystate.py
                      class HistoryState(statemachine.AbstractStateMixin, statemachine.QHistoryState):
                          def _get_map(self):
                              maps = super()._get_map()
                              maps |= {"historyType": HISTORY_TYPE}
                              return maps
                      
                          def set_history_type(
                              self, typ: HistoryTypeStr | statemachine.QHistoryState.HistoryType
                          ):
                              """Set history type to use.
                      
                              Args:
                                  typ: history type to use
                              """
                              self.setHistoryType(HISTORY_TYPE.get_enum_value(typ))
                      
                          def get_history_type(self) -> HistoryTypeStr:
                              """Return current history type.
                      
                              Returns:
                                  history type
                              """
                              return HISTORY_TYPE.inverse[self.historyType()]
                      

                      get_history_type() -> HistoryTypeStr

                      Return current history type.

                      Source code in prettyqt/statemachine/historystate.py
                      def get_history_type(self) -> HistoryTypeStr:
                          """Return current history type.
                      
                          Returns:
                              history type
                          """
                          return HISTORY_TYPE.inverse[self.historyType()]
                      

                      set_history_type(typ: HistoryTypeStr | statemachine.QHistoryState.HistoryType)

                      Set history type to use.

                      Parameters:

                      Name Type Description Default
                      typ HistoryTypeStr | HistoryType

                      history type to use

                      required
                      Source code in prettyqt/statemachine/historystate.py
                      def set_history_type(
                          self, typ: HistoryTypeStr | statemachine.QHistoryState.HistoryType
                      ):
                          """Set history type to use.
                      
                          Args:
                              typ: history type to use
                          """
                          self.setHistoryType(HISTORY_TYPE.get_enum_value(typ))
                      

                      StateMachine

                      Bases: StateMixin, QStateMachine

                      Source code in prettyqt/statemachine/statemachine.py
                      class StateMachine(statemachine.state.StateMixin, statemachine.QStateMachine):
                          def _get_map(self):
                              maps = super()._get_map()
                              maps |= {"globalRestorePolicy": statemachine.state.RESTORE_POLICY}
                              return maps
                      
                          def __add__(self, other: statemachine.QAbstractState) -> StateMachine:
                              self.addState(other)
                              return self
                      
                          def get_error(self) -> ErrorStr:
                              return ERROR.inverse[self.error()]
                      
                          def post_event(
                              self,
                              event: QtCore.QEvent,
                              priority: PriorityStr | statemachine.QStateMachine.EventPriority = "normal",
                          ):
                              self.postEvent(event, PRIORITY.get_enum_value(priority))
                      
                          def set_global_restore_policy(
                              self,
                              policy: statemachine.state.RestorePolicyStr | statemachine.State.RestorePolicy,
                          ):
                              """Set restore policy to use.
                      
                              Args:
                                  policy: restore policy to use
                              """
                              self.setGlobalRestorePolicy(
                                  statemachine.state.RESTORE_POLICY.get_enum_value(policy)
                              )
                      
                          def get_global_restore_policy(self) -> statemachine.state.RestorePolicyStr:
                              """Return current restore policy.
                      
                              Returns:
                                  restore policy
                              """
                              return statemachine.state.RESTORE_POLICY.inverse[self.globalRestorePolicy()]
                      

                      get_global_restore_policy() -> statemachine.state.RestorePolicyStr

                      Return current restore policy.

                      Source code in prettyqt/statemachine/statemachine.py
                      def get_global_restore_policy(self) -> statemachine.state.RestorePolicyStr:
                          """Return current restore policy.
                      
                          Returns:
                              restore policy
                          """
                          return statemachine.state.RESTORE_POLICY.inverse[self.globalRestorePolicy()]
                      

                      set_global_restore_policy(policy: statemachine.state.RestorePolicyStr | statemachine.State.RestorePolicy)

                      Set restore policy to use.

                      Parameters:

                      Name Type Description Default
                      policy RestorePolicyStr | RestorePolicy

                      restore policy to use

                      required
                      Source code in prettyqt/statemachine/statemachine.py
                      def set_global_restore_policy(
                          self,
                          policy: statemachine.state.RestorePolicyStr | statemachine.State.RestorePolicy,
                      ):
                          """Set restore policy to use.
                      
                          Args:
                              policy: restore policy to use
                          """
                          self.setGlobalRestorePolicy(
                              statemachine.state.RESTORE_POLICY.get_enum_value(policy)
                          )
                      

                      StateMixin

                      Bases: AbstractStateMixin, _StateBase

                      Source code in prettyqt/statemachine/state.py
                      class StateMixin(statemachine.AbstractStateMixin, _StateBase):
                          def _get_map(self):
                              maps = super()._get_map()
                              maps |= {"childMode": CHILD_MODE}
                              return maps
                      
                          def set_child_mode(self, mode: ChildModeStr | statemachine.QState.ChildMode):
                              """Set child mode to use.
                      
                              Args:
                                  mode: child mode to use
                              """
                              self.setChildMode(CHILD_MODE.get_enum_value(mode))
                      
                          def get_child_mode(self) -> ChildModeStr:
                              """Return current child mode.
                      
                              Returns:
                                  child mode
                              """
                              return CHILD_MODE.inverse[self.childMode()]
                      

                      get_child_mode() -> ChildModeStr

                      Return current child mode.

                      Source code in prettyqt/statemachine/state.py
                      def get_child_mode(self) -> ChildModeStr:
                          """Return current child mode.
                      
                          Returns:
                              child mode
                          """
                          return CHILD_MODE.inverse[self.childMode()]
                      

                      set_child_mode(mode: ChildModeStr | statemachine.QState.ChildMode)

                      Set child mode to use.

                      Parameters:

                      Name Type Description Default
                      mode ChildModeStr | ChildMode

                      child mode to use

                      required
                      Source code in prettyqt/statemachine/state.py
                      def set_child_mode(self, mode: ChildModeStr | statemachine.QState.ChildMode):
                          """Set child mode to use.
                      
                          Args:
                              mode: child mode to use
                          """
                          self.setChildMode(CHILD_MODE.get_enum_value(mode))