diff options
| author | historia <historiavg@proton.me> | 2026-08-28 02:27:10 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-28 02:27:10 -0400 |
| commit | a7c653313d2bb1e185cfbc3f0f52c2fe33218600 (patch) | |
| tree | f28f57fa5509ddb54176116cc4cc1198d034e9ff /app/ui/tui.py | |
| parent | 975053f1789771ba5cb9dbe50ba7fe0aa396f0ab (diff) | |
| download | tts-audiobook-generator-a7c653313d2bb1e185cfbc3f0f52c2fe33218600.tar.gz | |
feat: qwen-tts backend widgets updated to same style as audio.cpp
Diffstat (limited to 'app/ui/tui.py')
| -rw-r--r-- | app/ui/tui.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/ui/tui.py b/app/ui/tui.py index 7da1dd1..e2216a3 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -1063,16 +1063,25 @@ def form(scr, title: str, fields: Sequence[dict], field["value"] = values[(index + 1) % len(values)] run_on_change(field) - def display_value(field: dict) -> str: + def display_value(field: dict, fields: list) -> str: if field.get("kind") == "bool": return "Yes" if field["value"] else "No" if field.get("kind") == "dir": value = field["value"] return str(value) if value is not None else "" - if field.get("kind") == "toggle": - for label, value in field.get("choices") or []: - if value == field["value"]: - return label + if field.get("kind") in ("toggle", "choice"): + # Show the selected value's label, not the raw value: a + # (label, value) choice's label is what the pick menu shows, + # so the row reads the same before and after the pick (the + # Backend key "qwen" displays as its label "qwen-tts"). + choices = field.get("choices") or [] + if callable(choices): + choices = choices(fields) + if choices and isinstance(choices[0], (tuple, list)) \ + and len(choices[0]) == 2: + for label, value in choices: + if value == field["value"]: + return label return str(field["value"]) while True: @@ -1097,7 +1106,7 @@ def form(scr, title: str, fields: Sequence[dict], name = f"{field_label(field)}:".ljust(label_w + 1) frame.mark_segments( [(name, frame.theme["body"]), - (" " + display_value(field), frame.theme["input"])], + (" " + display_value(field, fields), frame.theme["input"])], selectable=True, align="left") frame.cursor = None if on_buttons else field_rows[cursor] frame.buttons = (list(buttons), btn_index if on_buttons else None) |
