lookatme.widgets.table module

Defines a basic Table widget for urwid

class lookatme.widgets.table.SortSetting[source]

Bases: object

ASCENDING = 1
DEFAULT = 0
DESCENDING = 2
get_casting(data: List[bytes]) → Callable[source]
get_header_idx() → int[source]
set_header_idx(idx)[source]
set_indicator(idx, text: str)[source]
sort_data(contents: List[Tuple[int, bytes]]) → List[int][source]

Sort the provided data based on the bytes values in the tuples

class lookatme.widgets.table.Table(ctx: lookatme.render.context.Context, header: Dict[KT, VT], body: Optional[Dict[KT, VT]])[source]

Bases: urwid.container.Pile

calc_column_maxes()[source]
create_cells(rows, base_spec=None, header=False) → List[List[urwid.container.Pile]][source]

Create the rows for the body, optionally calling a modifier function on each created cell Text. The modifier must accept an urwid.Text object and must return an urwid.Text object.

gen_cells(row: List[urwid.container.Pile], row_specs: Tuple[urwid.display_common.AttrSpec, urwid.display_common.AttrSpec]) → List[Tuple[int, urwid.container.Pile]][source]
gen_contents()[source]

Calculate and set the column maxes for this table

get_table_rows()[source]

Get the current rows in this table. This is where sorting should happen!

normalize_body()[source]

Normalize the cells in the body - truncate all cells that go beyond the number of headers, and add blank cells if we’re missing any

on_header_click(w: urwid.widget.Widget)[source]
row_specs(row_idx: int, is_header: bool) → Tuple[urwid.display_common.AttrSpec, urwid.display_common.AttrSpec][source]

Return the row-specific specs (text and general) for the given row

signals = ['change']
validate_row(row: Dict[KT, VT])[source]

Validate that the provided row is a tr_open, with th_open or td_open children.

validate_row_container(container: Dict[KT, VT])[source]

Validate that the list of rows is valid. See validate_row for more details.

watch_header(idx: int, w: urwid.widget.Widget)[source]

Watch the provided widget w for changes