diff options
Diffstat (limited to 'app/ui/tui.py')
| -rw-r--r-- | app/ui/tui.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/app/ui/tui.py b/app/ui/tui.py index 60a77dc..7d104a4 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -1459,7 +1459,8 @@ def checkbox_tree(scr, title: str, families: List[dict], expand_all: bool = False, back_value: object = None, checked: Optional[set] = None, - start_on_buttons: bool = False) -> List[Tuple[int, str]]: + start_on_buttons: bool = False, + allow_empty: bool = False) -> List[Tuple[int, str]]: """Pick model families and packages from an expandable tree. FAMILIES is a list of dicts (one per family) shaped like:: @@ -1489,6 +1490,10 @@ def checkbox_tree(scr, title: str, families: List[dict], family — the "modify an existing config" entry point. START_ON_BUTTONS puts the initial focus on Confirm, so Enter accepts the tree as it stands (the seeded modify selection) immediately. + ALLOW_EMPTY lets Confirm accept a selection with nothing checked + (returning []) — for pickers where unchecking means removing, a + fully-unchecked tree is a meaningful answer; the default keeps the + "Check at least one model package" flash. A "[recommended]" tag is shown only when a family has more than one option — a single option needs no tag. Family and option rows are left-justified like a DOS list. Esc (or @@ -1575,7 +1580,10 @@ def checkbox_tree(scr, title: str, families: List[dict], frame.status = None else: node = nodes[cursor] - frame.status = (families[node[1]].get("detail", ""), "info") + detail = families[node[1]].get("detail", "") + # A family without a detail draws no status line at all + # (an empty string would still occupy the row). + frame.status = (detail, "info") if detail else None frame.draw() curses = frame.curses key = frame.get_key(cancel_keys=()) @@ -1595,7 +1603,7 @@ def checkbox_tree(scr, title: str, families: List[dict], elif key in (10, 13): if btn_index == 0: # Confirm selection = accept() - if selection: + if selection or allow_empty: return selection frame.flash("Check at least one model package", "err") else: # Back |
