Karana.KUtils.MultibodyTUI.mode#
Attributes#
Classes#
Cycles through a finite list of literals representing modes |
Module Contents#
- Karana.KUtils.MultibodyTUI.mode.T#
- class Karana.KUtils.MultibodyTUI.mode.ModeCycler[source]#
Bases:
Generic[T]Cycles through a finite list of literals representing modes
It’s somewhat awkward in Python to access the generic type at runtime. This class provides an abstraction that handles the gory details so that it’s straightforward to bind a typing.Literal to the generic and use the literal options both in type hints and at runtime.
- Should be specialized with a typing.Literal - for example:
FooBarOptions = typing.Literal[“foo”, “bar”] FooBarCycler = ModeCycler[FooBarOptions]
Then FooBarCycler is a class that can be instantiated to cycle between modes “foo” and “bar”.
- property mode: T#
The current mode
- property modes: list[T]#
The list of available modes
- property index: int#
The current index into the mode list