diff options
| author | historia <historiavg@proton.me> | 2026-08-25 19:03:09 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-25 19:03:09 -0400 |
| commit | 8c9a782dfe94525dc5f0893c98fd19543648264b (patch) | |
| tree | fdff70d967ef06f0da560ca284842427cbe647a8 /app/ui/tui.py | |
| parent | 64e9940d43fad1bc5908b39673b03e4fdc1e8f2f (diff) | |
| download | tts-audiobook-generator-8c9a782dfe94525dc5f0893c98fd19543648264b.tar.gz | |
fix: tui errors wait for getch()
Diffstat (limited to 'app/ui/tui.py')
| -rw-r--r-- | app/ui/tui.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/app/ui/tui.py b/app/ui/tui.py index d675946..b1b18f1 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -123,17 +123,22 @@ def flash(scr, text: str, kind: str = "warn") -> None: Used by the hub for "not set up yet"-style messages. KIND is a theme key (warn/err/ok/info). The notice itself is the dialog's only content (no "Notice" heading); Esc dismisses it (it does not abort). + A timed-out getch (-1; the screen may still be in a redraw cadence) + is ignored so the notice really waits for a key. """ frame = Frame(scr, "", "Press any key to continue Esc = back") frame.mark(text, frame.theme.get(kind, frame.theme["body"])) frame.cursor = None frame.draw() - try: - key = scr.getch() - except KeyboardInterrupt: - raise WizardCancelled() from None - if key == 3: # Ctrl-C still aborts - raise WizardCancelled() + while True: + try: + key = scr.getch() + except KeyboardInterrupt: + raise WizardCancelled() from None + if key == 3: # Ctrl-C still aborts + raise WizardCancelled() + if key != -1: + return # On screens without typed text, Esc and 'q' mean the same thing: go @@ -581,12 +586,15 @@ class Frame: """Show TEXT on the status line until any key is pressed.""" self.status = (text, kind) self.draw() - try: - key = self.scr.getch() - if key == 3: # Ctrl-C still aborts - raise WizardCancelled() - except KeyboardInterrupt: - raise WizardCancelled() from None + while True: + try: + key = self.scr.getch() + if key == 3: # Ctrl-C still aborts + raise WizardCancelled() + except KeyboardInterrupt: + raise WizardCancelled() from None + if key != -1: + break self.status = None def edit_status(self, prompt: str = "") -> Optional[str]: |
