ConnectOnionConnectOnion

pick

Single-select menu with keyboard navigation

Quick Start

main.py
1from connectonion.tui import pick 2 3choice = pick("Pick a color", ["Red", "Green", "Blue"]) 4# Press 1 → "Red", 2 → "Green", 3 → "Blue" 5# Or use arrow keys + Enter
Python REPL
Interactive
Pick a color
 
❯ 1 Red
2 Green
3 Blue
 
↑↓ navigate 1-9 jump Enter select

Options

Simple List

main.py
1choice = pick("Select model", ["gpt-4", "claude-3", "gemini"]) 2# Returns: "gpt-4" (selected string)

With Descriptions

main.py
1choice = pick("Send email?", [ 2 ("Yes, send it", "Send immediately"), 3 ("Auto approve", "Skip approval for this recipient"), 4 ("No", "Cancel"), 5])

With "Other" Option

main.py
1choice = pick("Continue?", ["Yes", "No"], other=True) 2# Adds "Other..." option for custom text input

Keyboard Controls

KeyAction
↑/↓Navigate up/down
1-9Jump to option
EnterConfirm selection
EscCancel

API

main.py
1pick( 2 title: str, # Question to display 3 options: list, # Strings or (label, description) tuples 4 other: bool = False, # Add "Other..." option 5 console: Console = None 6) -> str # Returns selected label

Example Output

Pick a color

  ❯ 1  Red
    2  Green
    3  Blue

↑↓ navigate  1-9 jump  Enter select