libui.node — Node Base & Build Infrastructure¶
Node base class and build infrastructure for the declarative UI layer.
- class libui.node.BuildContext(window=None)¶
Bases:
objectCarries shared state during the build phase.
- class libui.node.Node(**kwargs)¶
Bases:
objectBase descriptor for a UI element. Lightweight — does not create widgets.
Subclasses override
create_widget()and optionallyattach_children().- create_widget(ctx: BuildContext) Any¶
- build(ctx: BuildContext) Any¶
Materialise the widget tree rooted at this node.
- attach_children(widget: Any, ctx: BuildContext) None¶
Override to add children to the widget.
- libui.node.make_two_way(node: Node, widget, prop: str, state: State, event: str, user_cb=None, _wrap_cb: bool = True) None¶
Set up two-way binding between a State and a widget property.
State -> widget: subscribe to state changes and set widget prop. Widget -> state: register the widget event callback to push into state. The reentrancy guard in State.set() prevents cycles.
If user_cb is provided it is called with the current value after the State has been updated.