Reference · Panelith 0.1.0 · plain HTML edition; the interactive edition has search and live examples
ListSource
On this page 3 sections
A ListSource provides rows for the drawer, the command bar (under its sigil) and ListPanes. See Lists and the drawer.
Attributes#
| Attribute | Type | Default | What it changes |
|---|---|---|---|
id |
str |
required | the id: what refresh_list, list:<id> and cycler refer to |
title |
str |
'' |
the drawer heading and the bar's section name |
sigil |
str | None |
None |
one character that lists this source in the command bar — Options: any single character other than the command sigil |
drawer |
bool |
True |
whether the list has a drawer |
columns |
list[str | ListColumn] |
[] |
key strings or ListColumn(key, label, width, grow, mono) |
search |
list[str] |
[] |
row keys the search box matches |
facets |
list[str] |
[] |
row keys that get a filter button each |
status |
str | ListStatus | None |
None |
a key (marks done with ✓) or ListStatus(key, marks, tones) |
row_action |
str | None |
None |
command id run with {row} when a row is chosen |
empty_text |
str |
'Nothing here yet' |
what an empty list says |
live |
bool |
False |
the server searches: every keystroke fetches /api/lists/ |
snippet |
str | None |
None |
a row key shown dim under the row's columns (a search excerpt) |
tree |
str | None |
None |
a row key holding an indent level (0, 1, 2): level 0 rows read as headings, deeper rows sit indented beneath them |
chips |
list[str] |
[] |
facets (from facets) shown as a row of toggle chips above the rows instead of a filter button |
abstract |
bool |
False |
keeps a base class out of the registry |
Hooks and methods#
rows#
rows(self, ctx: Context) -> list[dict[str, Any]]
Every row, as dicts with an id; called when the drawer opens and on
refresh_list. A live list answers queries through search_rows instead.
search_rows#
search_rows(self, ctx: Context, query: str) -> list[dict[str, Any]]
The rows for query when the list is live. The default is a
case-insensitive substring match over the search fields, so live = True
alone works; a docs search or a database query overrides this.
spec#
spec() -> s.ListSpec
ListColumn and ListStatus#
| Field | Type | Default | Description |
|---|---|---|---|
key |
str |
required | the row key |
label |
str | None |
None |
the header text; the key when omitted |
width |
int | None |
None |
a fixed width in pixels |
grow |
bool |
False |
take the spare width |
mono |
bool |
False |
monospace, for ids and figures |
| Field | Type | Default | Description |
|---|---|---|---|
key |
str |
required | the row key the marks and tones read |
marks |
dict[str, str] |
{} |
value -> glyph, e.g. {'solved': '✓'} |
tones |
dict[str, str] |
{} |
value -> 'ok' | 'half' | 'dim' |