Back to Projects
TUIX v0.6Beta

Last Updated: 2026-08-14

Your First Widget

This walkthrough builds a tiny interactive choice screen. It uses the current v0.6 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 core, scene, content_builder, input
from tuix.core import object as objects

core.init()
content_builder.register_standard()

scene.init_scene(b'Main')
scene.select_scene(b'Main')
input.listen()

uid = objects.create_object(content_builder.CHOICE, b'Main', 0.4, 0.35, 0.2, 0.3)
choice = objects.get_object_by_uid(uid)
objects.tuix_choice_set_options(choice, [b'Red', b'Green', b'Blue'])
scene.set_focus(b'Main', uid)

try:
    while True:
        core.main_loop()
        if objects.tuix_choice_is_confirmed(choice):
            selected = objects.tuix_choice_get_result(choice)
            break
finally:
    input.stop()
    core.shutdown()

print('Selected index:', selected)

Step Notes

  • content_builder.register_standard() installs every built-in native builder under the 'tuix' namespace, including layout, viewport, and modal widgets.
  • objects.get_object_by_uid(uid) returns the handle used by widget-specific functions.
  • scene.set_focus(b"Main", uid) chooses the keyboard input target. Mouse clicks can also switch targets through the compositor hitmap.
  • Manual feed_input calls remain as legacy compatibility shims, but normal v0.6 applications rely on core.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 buffer.set_buffer_layout_slot_by_uid(...).