diff options
Diffstat (limited to 'app/ui')
| -rw-r--r-- | app/ui/hub.py | 7 | ||||
| -rw-r--r-- | app/ui/tui.py | 14 |
2 files changed, 19 insertions, 2 deletions
diff --git a/app/ui/hub.py b/app/ui/hub.py index 6a94096..5b18869 100644 --- a/app/ui/hub.py +++ b/app/ui/hub.py @@ -14,6 +14,7 @@ main menu. import json import re +import shutil from pathlib import Path from typing import Optional, Tuple @@ -84,9 +85,13 @@ def _hub_menu(stdscr) -> Optional[tuple]: options.append(("Settings...", "settings")) options.append(("Quit", "quit")) rows = [(st.label, *_status_mark(st)) for st in statuses] + notice_lines = None + if shutil.which("ffmpeg") is None: + notice_lines = [("Warning: ffmpeg not installed!", "err")] choice = tui.menu( stdscr, "tts-audiobook-generator", options, - table_title="Backend status", table_rows=rows) + table_title="Backend status", table_rows=rows, + notice_lines=notice_lines) if choice is None or choice == "quit": return None if choice == "convert": diff --git a/app/ui/tui.py b/app/ui/tui.py index 9047f36..c3d79f6 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -611,7 +611,8 @@ def menu(scr, title: str, options: Sequence[tuple], default_index: int = 0, help_lines: Optional[Sequence[str]] = None, back_value: object = None, table_title: Optional[str] = None, - table_rows: Optional[Sequence[tuple]] = None): + table_rows: Optional[Sequence[tuple]] = None, + notice_lines: Optional[Sequence[Tuple[str, str]]] = None): """Show OPTIONS as (label, value) pairs; return the chosen value. The cursor starts on DEFAULT_INDEX; Enter returns the highlighted @@ -628,6 +629,11 @@ def menu(scr, title: str, options: Sequence[tuple], default_index: int = 0, hub to show each backend's state (unavailable / installed / running) in matching columns with color. + NOTICE_LINES render above the table (and after HELP_LINES): each + entry is (text, kind) where KIND is a theme key, so the hub can warn + in red (e.g. "Warning: ffmpeg not installed!") without polluting the + status table. + Esc (or 'q') aborts the wizard unless BACK_VALUE is given (not None), in which case Esc returns it so the caller can fall back a screen. """ @@ -642,6 +648,12 @@ def menu(scr, title: str, options: Sequence[tuple], default_index: int = 0, frame.mark(line, frame.theme["dim"]) if help_lines: frame.mark("") + if notice_lines: + for text, kind in notice_lines: + frame.mark(text, + frame.theme.get(kind, frame.theme["body"]), + align="left") + frame.mark("") if table_rows: if table_title: frame.mark(table_title, frame.theme["dim"], align="left") |
