Back to Projects
TUIX v0.2.1Beta

Last Updated: 2026-05-20

Examples

The repository includes five example scripts in the examples/ directory that demonstrate each widget type and multi-widget layouts.

Progressbar Animation

examples/ex_progressbar.py — Two progress bars animating at different speeds with custom styling.

python examples/ex_progressbar.py
  • Bar A fills at full speed (0 → 100% in 100 frames)
  • Bar B fills at half speed (0 → 50%)
  • Custom characters ('#'/'-') and RGB colors per bar
  • ESC to quit early

Choice Menu

examples/ex_choice.py — Color palette selector with five options.

python examples/ex_choice.py
  • 6 color options with pre-defined RGB values
  • Arrow keys to navigate, Enter to confirm
  • Prints selected color name and RGB to stdout
  • ESC to cancel

Canvas Drawing

examples/ex_canvas.py — Animated bouncing ball with real-time graphics.

python examples/ex_canvas.py
  • Full-screen canvas with bordered frame
  • Bouncing ball with HSL color cycling
  • Real-time FPS counter displayed in the top-right corner
  • Ball bounces within the inner area with velocity reversal on boundaries
  • Runs until any key is pressed

Multi-Widget Layout

examples/ex_multi_widget.py — Three widgets displayed simultaneously.

python examples/ex_multi_widget.py
  • Progressbar (top): fills over 5 seconds as a countdown
  • Choice widget (left): 4 options (Option A/B/C/D)
  • Input widget (right): text entry with placeholder
  • Prints summary of all widget results after session ends
  • ESC to force quit
Input Routing in v0.2.1When combining multiple interactive widgets, use scenes.set_focus(scene_name, uid) to select the active input target. This prevents Choice and Input widgets from reacting to the same keystrokes at the same time.

Full Widget Showcase

examples/builders.py — Sequential demo of all four widget types.

python examples/builders.py
  • Progressbar: animates from 0 to 100% with custom '#'/'-' styling
  • Choice: 5-option color selector with keyboard navigation
  • Input: text entry with placeholder 'Type your name...'
  • Canvas: draws borders, circles, lines, rectangles, text, and a smiley sprite

The showcase demonstrates the complete widget lifecycle: init → register → create scene → input → create object → configure → render loop → get result → cleanup.