Getting Started with TUIX Core
This guide walks you through the prerequisites, import, and basic workflow for building terminal user interfaces with TUIX Core.
Prerequisites
Before starting, ensure you have Python 3.8+ installed. TUIX Core depends on wcwidth for accurate Unicode character width measurement. Your terminal must support ANSI escape sequences and 24-bit RGB colors (most modern terminals do).
Import
from tuix.core import TuixEngine
engine = TuixEngine()Creating a TuixEngine instance initializes all five subsystems: engine.styles (Styles), engine.components (ComponentAPI), engine.layout (LayoutEngine), engine.render (RenderEngine), and engine.input (InputHandler).
Basic Workflow
- Instantiate TuixEngine — initializes all subsystems
- Create a component via engine.components.create(type, id)
- Configure properties via engine.components.set_property()
- Set layout dimensions and margin modes via engine.layout
- Optionally customize styles via engine.styles
- Call engine.render.draw() to render and start the input loop
Quick Example
from tuix.core import TuixEngine
engine = TuixEngine()
# 1. Create a component
engine.components.create("choice", "main_menu")
# 2. Set properties
engine.components.set_property(
id="main_menu", param="label", value="Select an option:"
)
engine.components.set_property(
id="main_menu", param="choices",
value=[[{"name": "Option 1", "action": None}]]
)
# 3. Render UI
engine.render.draw()
# Input is automatically handled in draw() for choice componentsWhat Happens on draw()
When you call engine.render.draw(), the framework:
- Clears the terminal screen
- Computes layout dimensions proportional to terminal size
- Renders the component with Unicode box-drawing borders and styled text
- Enters the input loop — arrow keys navigate the menu, Enter confirms selection
Next Steps
Head to the Installation guide to install TUIX Core, then follow the First Component tutorial to build a full interactive menu.