libui.widgets — Widget Nodes¶
Declarative widget nodes — split by category.
- class libui.widgets.VBox(*children: Node, padded: bool = True)¶
Bases:
NodeVertical box container.
- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- class libui.widgets.HBox(*children: Node, padded: bool = True)¶
Bases:
NodeHorizontal box container.
- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- class libui.widgets.Group(title: str | State[str], child: Node, margined: bool = True)¶
Bases:
NodeLabeled group container with a single child.
- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- class libui.widgets.Form(*rows: tuple, padded: bool = True)¶
Bases:
NodeTwo-column label-control form.
Children are
(label, node)tuples or(label, node, stretchy)triples.- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- class libui.widgets.Tab(*pages: tuple[str, Node], margined: bool = True)¶
Bases:
NodeTabbed container. Children are
("Page Name", node)tuples.- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- class libui.widgets.Grid(*cells: GridCell, padded: bool = True)¶
Bases:
NodeGrid layout container.
- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- class libui.widgets.GridCell(child: Node, left: int, top: int, xspan: int = 1, yspan: int = 1, hexpand: bool = False, halign=Align.FILL, vexpand: bool = False, valign=Align.FILL)¶
Bases:
objectPlacement descriptor for a child in a Grid.
- class libui.widgets.Label(text: str | State[str] | Computed[str] = '')¶
Bases:
NodeStatic text label.
- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- class libui.widgets.Button(text: str = '', on_clicked: Callable | None = None)¶
Bases:
NodeClickable button.
- create_widget(ctx)¶
- class libui.widgets.Entry(text: State[str] | str | None = None, type: str = 'normal', read_only: State[bool] | bool = False, on_changed: Callable | None = None)¶
Bases:
NodeSingle-line text entry with optional two-way binding.
- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.Checkbox(text: str = '', checked: State[bool] | bool = False, on_toggled: Callable | None = None)¶
Bases:
NodeCheckbox with optional two-way binding for
checked.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.Slider(min: int = 0, max: int = 100, value: State[int] | int = 0, has_tooltip: bool = True, on_changed: Callable | None = None)¶
Bases:
NodeHorizontal slider with optional two-way
valuebinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.Spinbox(min: int = 0, max: int = 100, value: State[int] | int = 0, on_changed: Callable | None = None)¶
Bases:
NodeNumeric spinbox with optional two-way
valuebinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.ProgressBar(value: State[int] | Computed[int] | int = 0)¶
Bases:
NodeProgress bar (one-way binding only).
- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- class libui.widgets.Combobox(items: Sequence[str] = (), selected: State[int] | int = 0, on_selected: Callable | None = None)¶
Bases:
NodeDrop-down combobox with optional two-way
selectedbinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.RadioButtons(items: Sequence[str] = (), selected: State[int] | int = -1, on_selected: Callable | None = None)¶
Bases:
NodeRadio button group with optional two-way
selectedbinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.EditableCombobox(items: Sequence[str] = (), text: State[str] | str = '', on_changed: Callable | None = None)¶
Bases:
NodeEditable combobox with optional two-way
textbinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.MultilineEntry(text: State[str] | str = '', wrapping: bool = True, read_only: State[bool] | bool = False, on_changed: Callable | None = None)¶
Bases:
NodeMulti-line text entry with optional two-way
textbinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.ColorButton(on_changed: Callable | None = None)¶
Bases:
NodeColor picker button.
- create_widget(ctx)¶
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.FontButton(on_changed: Callable | None = None)¶
Bases:
NodeFont picker button.
- create_widget(ctx)¶
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.DateTimePicker(type: str = 'datetime', on_changed: Callable | None = None)¶
Bases:
NodeDate/time picker.
- create_widget(ctx)¶
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.Separator(vertical: bool = False)¶
Bases:
NodeVisual separator line.
- create_widget(ctx)¶
- class libui.widgets.DrawArea(on_draw: Callable | None = None, on_mouse_event: Callable | None = None, on_mouse_crossed: Callable | None = None, on_drag_broken: Callable | None = None, on_key_event: Callable | None = None)¶
Bases:
NodeCustom drawing area with optional event callbacks.
- Callbacks:
- on_draw(ctx, area_w, area_h, clip_x, clip_y, clip_w, clip_h):
Called to paint the area. Must be synchronous.
- on_mouse_event(event_dict):
Mouse button/move. Keys: x, y, area_width, area_height, down, up, count, modifiers, held. May be async.
- on_mouse_crossed(left: bool):
Mouse entered (False) or left (True) the area. May be async.
- on_drag_broken():
OS interrupted a drag. May be async.
- on_key_event(event_dict) -> bool:
Key press/release. Keys: key, ext_key, modifier, modifiers, up. Return True to consume. Must be synchronous.
- create_widget(ctx)¶
- class libui.widgets.ScrollingDrawArea(on_draw: Callable | None = None, width: int = 1000, height: int = 1000, on_mouse_event: Callable | None = None, on_mouse_crossed: Callable | None = None, on_drag_broken: Callable | None = None, on_key_event: Callable | None = None)¶
Bases:
NodeScrollable custom drawing area with a fixed content size.
Same callbacks as DrawArea, plus width/height for the scrollable region.
- create_widget(ctx)¶
- class libui.widgets.DataTable(data: ListState, *columns: _ColumnDescriptor, on_row_clicked: Callable | None = None, on_row_double_clicked: Callable | None = None, on_header_clicked: Callable | None = None, on_selection_changed: Callable | None = None)¶
Bases:
NodeDeclarative table backed by a
ListState.Each row in the ListState is a dict. Column descriptors define which keys to display and how.
- create_widget(ctx)¶
- class libui.widgets.TextColumn(name: str, key: str, editable: bool = False, color_col: int = -1, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.CheckboxColumn(name: str, key: str, editable: bool = True, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.CheckboxTextColumn(name: str, checkbox_key: str, text_key: str, checkbox_editable: bool = True, text_editable: bool = False, text_color_col: int = -1, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.ButtonColumn(name: str, text_key: str, on_click: Callable | None = None, clickable: bool = True, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.ImageTextColumn(name: str, image_key: str, text_key: str, editable: bool = False, color_col: int = -1, width: int = -1)¶
Bases:
_ColumnDescriptor
Containers¶
Container widget nodes: VBox, HBox, Group, Form, Tab, Grid.
- class libui.widgets.containers.VBox(*children: Node, padded: bool = True)¶
Bases:
NodeVertical box container.
- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- class libui.widgets.containers.HBox(*children: Node, padded: bool = True)¶
Bases:
NodeHorizontal box container.
- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- class libui.widgets.containers.Group(title: str | State[str], child: Node, margined: bool = True)¶
Bases:
NodeLabeled group container with a single child.
- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- class libui.widgets.containers.Form(*rows: tuple, padded: bool = True)¶
Bases:
NodeTwo-column label-control form.
Children are
(label, node)tuples or(label, node, stretchy)triples.- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
- class libui.widgets.containers.Tab(*pages: tuple[str, Node], margined: bool = True)¶
Bases:
NodeTabbed container. Children are
("Page Name", node)tuples.- create_widget(ctx)¶
- attach_children(widget, ctx)¶
Override to add children to the widget.
Label¶
Label widget node.
Entry¶
Entry and MultilineEntry widget nodes.
- class libui.widgets.entry.Entry(text: State[str] | str | None = None, type: str = 'normal', read_only: State[bool] | bool = False, on_changed: Callable | None = None)¶
Bases:
NodeSingle-line text entry with optional two-way binding.
- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.entry.MultilineEntry(text: State[str] | str = '', wrapping: bool = True, read_only: State[bool] | bool = False, on_changed: Callable | None = None)¶
Bases:
NodeMulti-line text entry with optional two-way
textbinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
Checkbox¶
Checkbox widget node.
- class libui.widgets.checkbox.Checkbox(text: str = '', checked: State[bool] | bool = False, on_toggled: Callable | None = None)¶
Bases:
NodeCheckbox with optional two-way binding for
checked.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
Slider¶
Slider widget node.
- class libui.widgets.slider.Slider(min: int = 0, max: int = 100, value: State[int] | int = 0, has_tooltip: bool = True, on_changed: Callable | None = None)¶
Bases:
NodeHorizontal slider with optional two-way
valuebinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
Spinbox¶
Spinbox widget node.
- class libui.widgets.spinbox.Spinbox(min: int = 0, max: int = 100, value: State[int] | int = 0, on_changed: Callable | None = None)¶
Bases:
NodeNumeric spinbox with optional two-way
valuebinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
ProgressBar¶
ProgressBar widget node.
Combobox¶
Combobox and EditableCombobox widget nodes.
- class libui.widgets.combobox.Combobox(items: Sequence[str] = (), selected: State[int] | int = 0, on_selected: Callable | None = None)¶
Bases:
NodeDrop-down combobox with optional two-way
selectedbinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
- class libui.widgets.combobox.EditableCombobox(items: Sequence[str] = (), text: State[str] | str = '', on_changed: Callable | None = None)¶
Bases:
NodeEditable combobox with optional two-way
textbinding.- create_widget(ctx)¶
- bind_props(widget)¶
Bind State/Computed props to widget attributes.
- attach_callbacks(widget)¶
Register event callbacks on the widget.
Pickers¶
Picker widget nodes: ColorButton, FontButton, DateTimePicker.
- class libui.widgets.pickers.ColorButton(on_changed: Callable | None = None)¶
Bases:
NodeColor picker button.
- create_widget(ctx)¶
- attach_callbacks(widget)¶
Register event callbacks on the widget.
Separator¶
Separator widget node.
Drawing¶
Drawing area widget nodes.
- class libui.widgets.draw.DrawArea(on_draw: Callable | None = None, on_mouse_event: Callable | None = None, on_mouse_crossed: Callable | None = None, on_drag_broken: Callable | None = None, on_key_event: Callable | None = None)¶
Bases:
NodeCustom drawing area with optional event callbacks.
- Callbacks:
- on_draw(ctx, area_w, area_h, clip_x, clip_y, clip_w, clip_h):
Called to paint the area. Must be synchronous.
- on_mouse_event(event_dict):
Mouse button/move. Keys: x, y, area_width, area_height, down, up, count, modifiers, held. May be async.
- on_mouse_crossed(left: bool):
Mouse entered (False) or left (True) the area. May be async.
- on_drag_broken():
OS interrupted a drag. May be async.
- on_key_event(event_dict) -> bool:
Key press/release. Keys: key, ext_key, modifier, modifiers, up. Return True to consume. Must be synchronous.
- create_widget(ctx)¶
- class libui.widgets.draw.ScrollingDrawArea(on_draw: Callable | None = None, width: int = 1000, height: int = 1000, on_mouse_event: Callable | None = None, on_mouse_crossed: Callable | None = None, on_drag_broken: Callable | None = None, on_key_event: Callable | None = None)¶
Bases:
NodeScrollable custom drawing area with a fixed content size.
Same callbacks as DrawArea, plus width/height for the scrollable region.
- create_widget(ctx)¶
Table¶
DataTable widget node and column descriptors.
- class libui.widgets.table.TextColumn(name: str, key: str, editable: bool = False, color_col: int = -1, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.table.CheckboxColumn(name: str, key: str, editable: bool = True, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.table.CheckboxTextColumn(name: str, checkbox_key: str, text_key: str, checkbox_editable: bool = True, text_editable: bool = False, text_color_col: int = -1, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.table.ProgressColumn(name: str, key: str, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.table.ButtonColumn(name: str, text_key: str, on_click: Callable | None = None, clickable: bool = True, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.table.ImageColumn(name: str, key: str, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.table.ImageTextColumn(name: str, image_key: str, text_key: str, editable: bool = False, color_col: int = -1, width: int = -1)¶
Bases:
_ColumnDescriptor
- class libui.widgets.table.DataTable(data: ListState, *columns: _ColumnDescriptor, on_row_clicked: Callable | None = None, on_row_double_clicked: Callable | None = None, on_header_clicked: Callable | None = None, on_selection_changed: Callable | None = None)¶
Bases:
NodeDeclarative table backed by a
ListState.Each row in the ListState is a dict. Column descriptors define which keys to display and how.
- create_widget(ctx)¶