Back to Projects
TUIX v0.4Beta

Last Updated: 2026-05-20

Examples

The repository includes example scripts in examples/widgets/, examples/multimodal/, and examples/showcase/ that cover the current builder set, focus routing, and the higher-level sequential demos. v0.4 examples are aligned with automatic input handling and snapshot-first inspection APIs. Additional widget demos include button_and_badge_demo.py, menu_and_tags_demo.py, scroll_container_demo.py, and text_and_box_demo.py.

Progressbar Animation

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

python examples/widgets/progressbar_dual.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/widgets/choice_palette.py — Color palette selector with keyboard navigation.

python examples/widgets/choice_palette.py
  • Palette choices are rendered as keyboard-selectable menu entries
  • Arrow keys to navigate, Enter to confirm
  • Prints the selected color name and RGB to stdout
  • ESC to cancel

Canvas Drawing

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

python examples/widgets/canvas_bounce.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/multimodal/focus_routing.py — Keyboard and mouse focus routing across interactive widgets.

python examples/multimodal/focus_routing.py
  • Demonstrates how scene focus changes when interacting with multiple widgets
  • Uses keyboard and mouse input together instead of treating them separately
  • Exercises focus handoff between choice and text input widgets
  • Highlights how hitmap-based picking keeps click handling deterministic
  • ESC to force quit
Input Routing in v0.4When combining multiple interactive widgets, use scenes.set_focus(scene_name, uid) to select the active input target. v0.4 also routes mouse clicks through the compositor hitmap before dispatching builder handlers, which keeps visible-widget targeting consistent.
Snapshot APIsv0.4 examples prefer lock-safe snapshot APIs (buffers.get_buffer_snapshot / buffers.get_buffer_snapshot_by_uid, objects.get_object_snapshot_by_uid, and input.peek_snapshot()) for read-only inspection over raw pointer getters.

Full Widget Showcase

examples/showcase/sequential_journey.py — Sequential demo that walks through the core widget types and interaction flow.

python examples/showcase/sequential_journey.py
  • Progressbar, choice, input, and canvas are exercised in order
  • Shows the standard register -> create -> configure -> render flow
  • Good smoke test for the native builder pipeline
  • Useful as a quick validation that the compiled core is wired correctly

Other showcase demos in the repository include buffer_hierarchy_demo.py and scene_stats_demo.py for buffer layering and scene instrumentation.