ankira / wizard.py
nofater's picture
mvp
2a0825b
Raw
History Blame Contribute Delete
917 Bytes
"""Navigation for the 4-step dictation wizard.
The UI is four ``gr.Group`` views stacked in one column; exactly one is visible
at a time. ``nav`` is the single source of truth for "show this step, hide the
rest" — handlers append its result to their outputs to move between steps. Kept
free of flat ``app`` imports so it can be imported both as ``wizard`` (Space
root) and ``space.wizard`` (repo root), and unit-tested without the app."""
import gradio as gr
# Order matters: it's the order the view Groups are created in build_ui and the
# order nav() returns visibility updates.
VIEWS = ("input", "listen", "upload", "results")
def nav(target: str) -> list:
"""Visibility updates for the four views; only ``target`` is shown."""
if target not in VIEWS:
raise ValueError(f"unknown view: {target!r} (expected one of {VIEWS})")
return [gr.update(visible=(view == target)) for view in VIEWS]