TUIX v0.5Beta
Your First Widget
This walkthrough builds a tiny interactive choice screen. It uses the current v0.5 object access pattern: create an object, get its object handle by UID, configure it, then let the frame loop route input automatically.
Complete Example
from tuix.core import engine, builders, scenes, objects, input
engine.init()
builders.register_standard()
scenes.init_scene('Main')
scenes.select_scene('Main')
input.listen()
uid = objects.create_object(builders.CHOICE, 'Main', 0.4, 0.35, 0.2, 0.3)
choice = objects.get_object_by_uid(uid)
objects.tuix_choice_set_options(choice, ['Red', 'Green', 'Blue'])
scenes.set_focus('Main', uid)
try:
while True:
engine.main_loop()
if objects.tuix_choice_is_confirmed(choice):
selected = objects.tuix_choice_get_result(choice)
break
finally:
input.stop()
engine.shutdown()
print('Selected index:', selected)Step Notes
- builders.register_standard() installs every built-in native builder, including the v0.5 layout and viewport widgets.
- objects.get_object_by_uid(uid) returns the handle used by widget-specific functions.
- scenes.set_focus("Main", uid) chooses the keyboard input target. Mouse clicks can also switch targets through the compositor hitmap.
- Manual feed_input calls remain as compatibility helpers, but normal v0.5 applications rely on engine.main_loop().
Next Variation
To try layout composition, create a Row or Column and add children with objects.tuix_stack_add_object(...), then configure each child with buffers.set_buffer_layout_slot_by_uid(...).