Skip to content

API turboframe.ui.filter

rafageist edited this page Dec 4, 2026 · 4 revisions

turboframe.ui.filter

Source: turboframe/ui/filter.py. Generated from the code of TurboFrame 0.3.0 by tools/wiki_api.py.

A filter over a list or a tree: one line above it, typed into from the list itself.

With the list (or tree) focused, a letter, a digit or a sign goes to the filter, Backspace takes one back, Escape empties it; only the items that hold the filter (a substring, case ignored) stay. Space keeps its job (fold, choose).

  • FilteredList: a ListBox mixin. focused, focus_item() and select_item() stay the ListBox's own (the rows shown); current is the focused row as an index of the whole list, original() turns a shown row into one, and focus_original() puts the bar on an item (emptying the filter when it hides it).
  • FilteredTree: a Tree mixin. Shown: what matches, the nodes above it, and what hangs from a node that matches. filter_text_of(node) is what is matched (the label by default).
  • Filtered(widget): the filter line above widget, in a container.

Contents

PROMPT, matches, FilterLine, Filtered, FilteredList, FilteredTree

PROMPT

'» '

matches

def matches(text: str, query: str) -> bool

class FilterLine

class FilterLine(Static)
FilterLine(target: Widget)

» filter (3/40), or a dim » type to filter when empty, in the list's colours.

  • show() -> None

class Filtered

class Filtered(Vertical)
Filtered(widget: Widget, fill: bool = True, **kwargs)

The filter line, then widget; fill: take the room left (1fr), else as tall as the widget.

class FilteredList

class FilteredList(_Filter)

ListBox mixin (before ListBox in the bases): the items that hold the filter.

  • set_list(items: list[str]) -> None
  • apply_filter() -> None
  • filter_counts() -> tuple[int, int]
  • original(shown: int) -> int: The index in the whole list of a row shown (-1: none).
  • current (property): The focused item, as an index of the whole list (-1: nothing shown).
  • focus_original(index: int) -> None: The bar on an item of the whole list (the filter is emptied if it hides it).
  • tv_handle_key(event: events.Key) -> bool

class FilteredTree

class FilteredTree(_Filter)

Tree mixin (before Tree in the bases): what matches, what is above it, and what hangs from a node that matches (folds still fold, below a match).

  • process_label(label) -> Text: A label as it reads: Tree takes a str for Rich markup, and a commit's subject, a template's [/$products] or a JSON key would be read as markup (or fail as one).
  • filter_text_of(node) -> str
  • apply_filter() -> None
  • filter_counts() -> tuple[int, int]

Clone this wiki locally