Quick Start
This page shows the smallest useful lazy-cuh app: a focused list, relative line numbers, vim-style movement, and a typed selection message.
Minimal App
Section titled “Minimal App”from rich.text import Textfrom textual.app import App, ComposeResult
from lazy_cuh import LineNumberMode, LineNumberSpec, ListViewModel, ListViewSpec, NavigableItemfrom lazy_cuh.styles import LAZY_CUH_CSSfrom lazy_cuh.widgets import ItemSelectedMessage, ListViewWidget
class Demo(App): CSS = LAZY_CUH_CSS + """ ListViewWidget { height: 1fr; border: round ansi_default; border-title-color: ansi_default; padding: 0 1; }
ListViewWidget:focus { border: round ansi_green; border-title-color: ansi_green; } """
BINDINGS = [("q", "quit", "Quit")]
def compose(self) -> ComposeResult: model = ListViewModel( items=( NavigableItem(id="panels", label=Text("Composable panels")), NavigableItem(id="lists", label=Text("Item-oriented lists")), NavigableItem(id="keybars", label=Text("Context-aware keybars")), ), spec=ListViewSpec( width=60, line_numbers=LineNumberSpec(LineNumberMode.RELATIVE), ), ) widget = ListViewWidget(model, id="items") widget.border_title = "[1]-Items" yield widget
def on_mount(self) -> None: self.query_one("#items", ListViewWidget).focus()
def on_item_selected_message(self, message: ItemSelectedMessage) -> None: self.notify(f"Selected {message.item_id}")
if __name__ == "__main__": Demo(ansi_color=True).run()Run it with:
uv run python app.pyUse j and k to move, enter or space to select, and q to quit.
What lazy-cuh Owns
Section titled “What lazy-cuh Owns”The example separates the reusable framework pieces from Textual runtime code:
NavigableItemis semantic item data.ListViewModelrenders items, line numbers, wrapping, and cursor highlight.ListViewWidgetadapts the model to Textual and emits typed messages.LAZY_CUH_CSSprovides the transparent lazygit-style defaults.
The app still owns the actual behavior: selecting an item shows a notification, but a real app could translate that event into a command, modal, or domain action.
Next Guides
Section titled “Next Guides”- Use Build a List View for the pure list model.
- Use App Structure for the recommended full-app composition order.
- Use Textual Adapters for widget boundaries.
- Use App Shell when an app needs multiple panels and tabs.