Files
gniza4linux/tui/widgets/confirm_dialog.py
shuki 587149f062 Add Python Textual TUI replacing gum-based bash TUI
New tui/ package with 14 screens (main menu, backup, restore, targets,
remotes, snapshots, verify, retention, schedule, logs, settings, wizard),
3 custom widgets (folder picker, confirm dialog, operation log), async
backend wrapper, pure-Python config parser, and TCSS theme.

bin/gniza now launches Textual TUI when available, falls back to gum.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:39:48 +02:00

29 lines
969 B
Python

from textual.app import ComposeResult
from textual.screen import ModalScreen
from textual.widgets import Static, Button
from textual.containers import Horizontal, Vertical
class ConfirmDialog(ModalScreen[bool]):
BINDINGS = [("escape", "cancel", "Cancel")]
def __init__(self, message: str, title: str = "Confirm"):
super().__init__()
self._message = message
self._title = title
def compose(self) -> ComposeResult:
with Vertical(id="confirm-dialog"):
yield Static(self._title, id="cd-title")
yield Static(self._message, id="cd-message")
with Horizontal(id="cd-buttons"):
yield Button("Yes", variant="primary", id="cd-yes")
yield Button("No", variant="default", id="cd-no")
def on_button_pressed(self, event: Button.Pressed) -> None:
self.dismiss(event.button.id == "cd-yes")
def action_cancel(self) -> None:
self.dismiss(False)