Back to Projects
TUIX v0.3Beta

Last Updated: 2026-05-20

Builders API

The builders module (tuix.core.builders) provides constants for the four built-in widget types and registration helpers. In v0.3, builders also process input natively via their callbacks.

builders.register_standard()

from tuix.core import builders

result = builders.register_standard()

Registers all four built-in widget builders with the engine. Must be called after engine.init() and before creating any widgets. In v0.3, these builders are input-aware and integrate with automatic input handling in the frame loop.

ReturnsDescription
int0 on success, -1 on failure

Builder Constants

These byte string constants identify widget types when calling objects.create_object():

ConstantValueWidget Type
builders.CANVASb"CanvasBuilder"Free-draw surface with pixel-level control
builders.CHOICEb"ChoiceBuilder"Keyboard-navigable selection menu
builders.INPUTb"InputBuilder"Single-line text entry with cursor
builders.PROGRESSBARb"ProgressBarBuilder"Animated fill bar with customizable styling

Usage

from tuix.core import builders, objects

# Create one of each widget type
progressbar_uid = objects.create_object(builders.PROGRESSBAR, b"main", 0.5, 0.1, 0.0, 0.25)
choice_uid      = objects.create_object(builders.CHOICE,      b"main", 0.4, 0.5, 0.2, 0.3)
input_uid       = objects.create_object(builders.INPUT,       b"main", 0.4, 0.1, 0.8, 0.3)
canvas_uid      = objects.create_object(builders.CANVAS,      b"main", 1.0, 1.0, 0.0, 0.0)

Builder Internals

Each builder is a C struct (TuixBuilder) with metadata and five callback function pointers:

CallbackPurpose
create_stateAllocate and initialize per-widget state
destroy_stateFree per-widget state
handler_funcPer-frame update logic, including native input processing
build_contentRender widget state into a pixel buffer
on_resizeOptional: called when terminal dimensions change
v0.3 Input ModelManual calls such as objects.tuix_choice_feed_input() and objects.tuix_input_feed_input() remain available for compatibility, but the standard v0.3 flow is automatic input handling through builder callbacks.

Builders are looked up by name via linear search (tuix_get_builder_by_name). With only four built-in builders, this is effectively O(1).