Karana.KUtils.MultibodyTUI.mode#

Attributes#

T

Classes#

ModeCycler

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”.

copy() Self[source]#

Get a copy of self

__len__() int[source]#

The number of modes

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

next()[source]#

Change to the next mode in the list

prev()[source]#

Change to the previous mode in the list

reset()[source]#

Reset to the default mode