Skip to content

Wizards

Textual-free contracts for consumer-owned setup wizards.

WizardStep module-attribute

WizardStep = FormStep | ChoiceStep | ReviewStep

Choice dataclass

Choice(key: str, label: str, description: str)

description instance-attribute

description: str

key instance-attribute

key: str

label instance-attribute

label: str

ChoiceStep dataclass

ChoiceStep(
    key: str,
    title: str,
    choices: tuple[Choice, ...],
    purpose: str | None = None,
    kind: Literal[CHOICE] = WizardStepKind.CHOICE,
)

choices instance-attribute

choices: tuple[Choice, ...]

key instance-attribute

key: str

kind class-attribute instance-attribute

kind: Literal[CHOICE] = WizardStepKind.CHOICE

purpose class-attribute instance-attribute

purpose: str | None = None

title instance-attribute

title: str

FormStep dataclass

FormStep(
    key: str,
    title: str,
    fields: tuple[FieldSpec, ...],
    purpose: str | None = None,
    kind: Literal[FORM] = WizardStepKind.FORM,
)

fields instance-attribute

fields: tuple[FieldSpec, ...]

key instance-attribute

key: str

kind class-attribute instance-attribute

kind: Literal[FORM] = WizardStepKind.FORM

purpose class-attribute instance-attribute

purpose: str | None = None

title instance-attribute

title: str

ReviewChange dataclass

ReviewChange(
    field: str,
    before: object,
    after: object,
    sensitive: bool = False,
)

after instance-attribute

after: object

before instance-attribute

before: object

field instance-attribute

field: str

sensitive class-attribute instance-attribute

sensitive: bool = False

__repr__

__repr__() -> str

ReviewStep dataclass

ReviewStep(
    key: str,
    title: str,
    review: WizardReview,
    purpose: str | None = None,
    kind: Literal[REVIEW] = WizardStepKind.REVIEW,
)

key instance-attribute

key: str

kind class-attribute instance-attribute

kind: Literal[REVIEW] = WizardStepKind.REVIEW

purpose class-attribute instance-attribute

purpose: str | None = None

review instance-attribute

review: WizardReview

title instance-attribute

title: str

WizardController

Bases: Protocol

Consumer-owned state machine for one wizard session.

spec property

spec: WizardSpec

apply

apply() -> WizardResult

back

back() -> WizardSnapshot

cancel

cancel() -> WizardResult

review

review() -> WizardTransition

start

start() -> WizardSnapshot

submit

submit(values: Mapping[str, object]) -> WizardTransition

WizardDefinitionError

Bases: ValueError

Raised when a wizard declares duplicate or unusable keys.

WizardResult dataclass

WizardResult(
    status: WizardResultStatus,
    summary: str,
    detail: object | None = None,
    refresh_pages: frozenset[str] = frozenset(),
)

applied property

applied: bool

detail class-attribute instance-attribute

detail: object | None = None

refresh_pages class-attribute instance-attribute

refresh_pages: frozenset[str] = frozenset()

status instance-attribute

status: WizardResultStatus

summary instance-attribute

summary: str

WizardResultStatus

Bases: StrEnum

APPLIED class-attribute instance-attribute

APPLIED = 'applied'

CANCELLED class-attribute instance-attribute

CANCELLED = 'cancelled'

CONFLICTED class-attribute instance-attribute

CONFLICTED = 'conflicted'

FAILED class-attribute instance-attribute

FAILED = 'failed'

WizardReview dataclass

WizardReview(
    changes: tuple[ReviewChange, ...] = (),
    effects: tuple[str, ...] = (),
    warnings: tuple[str, ...] = (),
    ready_to_apply: bool = True,
)

Presentation-safe review data. Real candidates stay in the controller.

changes class-attribute instance-attribute

changes: tuple[ReviewChange, ...] = ()

effects class-attribute instance-attribute

effects: tuple[str, ...] = ()

ready_to_apply class-attribute instance-attribute

ready_to_apply: bool = True

warnings class-attribute instance-attribute

warnings: tuple[str, ...] = ()

WizardSnapshot dataclass

WizardSnapshot(
    spec: WizardSpec,
    step: WizardStep,
    step_index: int,
    step_count: int,
    values: Mapping[str, object] = dict(),
    issues: tuple[ValidationIssue, ...] = (),
    can_back: bool = False,
    can_next: bool = True,
    can_apply: bool = False,
    expected_revision: str | None = None,
)

Complete render state for one wizard moment.

can_apply class-attribute instance-attribute

can_apply: bool = False

can_back class-attribute instance-attribute

can_back: bool = False

can_next class-attribute instance-attribute

can_next: bool = True

expected_revision class-attribute instance-attribute

expected_revision: str | None = None

issues class-attribute instance-attribute

issues: tuple[ValidationIssue, ...] = ()

spec instance-attribute

spec: WizardSpec

step instance-attribute

step: WizardStep

step_count instance-attribute

step_count: int

step_index instance-attribute

step_index: int

values class-attribute instance-attribute

values: Mapping[str, object] = field(default_factory=dict)

__post_init__

__post_init__() -> None

WizardSpec dataclass

WizardSpec(
    key: str,
    title: str,
    purpose: str,
    apply_label: str = "Apply",
)

Stable wizard identity and operator-facing copy.

apply_label class-attribute instance-attribute

apply_label: str = 'Apply'

key instance-attribute

key: str

purpose instance-attribute

purpose: str

title instance-attribute

title: str

WizardStepKind

Bases: StrEnum

CHOICE class-attribute instance-attribute

CHOICE = 'choice'

FORM class-attribute instance-attribute

FORM = 'form'

REVIEW class-attribute instance-attribute

REVIEW = 'review'

WizardTransition dataclass

WizardTransition(
    snapshot: WizardSnapshot,
    issues: tuple[ValidationIssue, ...] = (),
)

issues class-attribute instance-attribute

issues: tuple[ValidationIssue, ...] = ()

snapshot instance-attribute

snapshot: WizardSnapshot

issues_status

issues_status(
    issues: Sequence[ValidationIssue],
) -> SemanticStatus

redact_wizard_value

redact_wizard_value(
    field: FieldSpec, value: object
) -> object

Return the presentation value for a field without exposing secrets.

validate_wizard_steps

validate_wizard_steps(steps: Sequence[WizardStep]) -> None

Generic wizard screen rendered from Textual-free wizard contracts.

WizardScreen

WizardScreen(controller: WizardController)

Bases: ModalScreen[WizardResult]

Reusable one-step-at-a-time wizard surface.

BINDINGS class-attribute

BINDINGS: list[tuple[str, str, str]] = [
    ("escape", "cancel", "Cancel")
]

action_cancel

action_cancel() -> None

compose

compose() -> ComposeResult

on_button_pressed async

on_button_pressed(event: Pressed) -> None

on_mount async

on_mount() -> None