TUIX v0.2.1Beta
Getting Started with TUIX Core
This guide covers prerequisites, the basic import pattern, and the standard workflow for building terminal UIs with TUIX Core v0.2.1.
Fast PathIf you want the shortest route, do this in order: Installation -> run the minimal example on this page -> continue with First Widget -> then open the API reference pages when you need details.
Recommended Reading Order
- Install the package and verify that engine.init() works on your machine.
- Read the workflow on this page so you understand the scene -> widget -> main loop model.
- Build the Choice example from First Widget before diving into the lower-level API pages.
Prerequisites
- Python 3.10 or later
- A terminal that supports ANSI escape sequences (most modern terminals)
- Truecolor (24-bit RGB) support recommended; ANSI256 and ANSI16 fallback is automatic
Windows UsersTUIX Core uses ReadConsoleInputW for native input capture on Windows. ANSI rendering works in cmd.exe, PowerShell, and Windows Terminal.
Import Pattern
TUIX Core exposes its API through individual modules under tuix.core. There is no single top-level class — you import the modules you need.
from tuix.core import engine, builders, scenes, registry, objects, buffers, inputStandard Workflow
Every TUIX application follows this sequence:
- Initialize the engine with engine.init()
- Register built-in widget types with builders.register_standard()
- Create a scene with scenes.init_scene(b"scene_name")
- Set the active scene via registry.registry.current_scene_name = b"scene_name"
- Start the input listener with input.listen()
- Create widgets with objects.create_object(builder, scene, width, height, margin_top, margin_left)
- Configure widgets using their specific API functions
- Run engine.main_loop() in a loop to render frames and process input
- Clean up: free buffers, stop input, shut down the engine
Minimal Example
from tuix.core import engine, builders, scenes, registry, objects, buffers, input
import time
# 1. Initialize
engine.init()
builders.register_standard()
# 2. Create and select a scene
scenes.init_scene(b"main")
registry.registry.current_scene_name = b"main"
# 3. Start input
input.listen()
# 4. Create a progressbar widget (full width, 10% height, centered at top)
uid = objects.create_object(
builders.PROGRESSBAR, b"main",
0.5, 0.1, # width_mod, height_mod
0.1, 0.25 # margin_top_mod, margin_left_mod
)
# 5. Get the object pointer for widget operations
buf = buffers.get_buffer_by_uid(uid)
obj = buf.contents.obj.contents
# 6. Set progress value
objects.tuix_progressbar_set_value(obj, 0.5)
# 7. Render loop
for i in range(100):
objects.tuix_progressbar_set_value(obj, i / 100.0)
engine.main_loop()
time.sleep(0.03)
# 8. Cleanup
buffers.free_buffer(b"main", uid)
input.stop()
engine.shutdown()What Happens Each Frame
Each call to engine.main_loop() executes this pipeline in C:
- Read terminal dimensions (resize detection)
- Commit any pending batch commands
- Execute subcycle handlers for enabled widgets (state updates, input processing)
- Resolve geometry: multiply widget modifiers by terminal size
- Call each widget's build_content to produce pixel buffers
- Composite all scene buffers into the final framebuffer
- Delta-render changed rows to the terminal
Next Steps
Head to Installation for setup instructions, then follow the First Widget tutorial to build an interactive choice menu from scratch.
When to Open the API ReferenceUse the Getting Started and First Widget pages to learn the flow. Use the API pages when you already know what subsystem you need: engine, scenes, builders, input, or a specific widget.