Skip to main content

Terminal Rendering EnginE (TREE)

A rendering engine for a terminal.

TREE Demo Image

Features

  • Support for Windows and Linux.
  • Basic drawing and other graphics operations.
  • Basic application and navigation support.
  • Several default controls, such as:
    • Label
    • Button
    • List
    • Dropdown
    • Text Input
    • Number Input
    • Checkbox
    • Progress Bar

Building and Linking

To use TREE in your project, you have two options:

  1. Add the header and source file directly to your project.
  2. Build TREE, and link it to your program.

C Library Build Scripts

  • TREE/Source/devenv.bat build release
  • TREE/Source/devenv.bat build debug

Python Binding (PyTREE)

This repository includes a CPython extension module and a higher-level Python OO wrapper.

Main pieces:

  • Native extension source: PyTREE/Source/PyTREE.c
  • Python wrapper classes: PyTREE/Test/pytre.py
  • Python demo: PyTREE/Test/demo.py

Install (after publishing to PyPI):

pip install pytre

Build the Python module:

  1. Open a terminal in PyTREE/Source.
  2. Run devenv.bat build.

Notes:

  • The script auto-builds TREE Release dependency if TREE.lib is missing.
  • Output module is created under PyTREE/Source/Build/build/lib.win-amd64-cpython-313/ (path varies by Python version/platform).

Run the Python demo:

  1. Open a terminal in PyTREE/Test.
  2. Run python demo.py.

PyPI Packaging and Publishing

Packaging files live in PyTREE/Source:

  • setup.py
  • pyproject.toml
  • MANIFEST.in

Build artifacts locally:

cd PyTREE/Source
python -m pip install --upgrade pip build twine
python -m build
python -m twine check dist/*

Publish manually:

python -m twine upload dist/*

Or publish with GitHub Actions:

  • Workflow file: .github/workflows/pypi-wheels.yml
  • Push a tag like pytre-v1.0.0 to trigger wheel+sdist publishing.

Intended Compatibility

  • Python: 3.9+
  • OS: Windows and Linux
  • Architectures built in CI by default: x86_64 / AMD64

Notes:

  • Linux clipboard operations depend on xclip being available.
  • macOS support is not enabled yet in CI, but can be added with a macos-latest runner.

Python API (OO Wrapper)

The recommended Python surface is class-based and uses the C extension under the hood.

Core classes:

  • Theme
  • Application
  • Button, Label, TextInput, ListControl, Dropdown, Checkbox, NumberInput, ProgressBar

Example:

import pytre as tree

tree.init()
tree.set_window_title("My App")

theme = tree.Theme()
app = tree.Application(16)

def on_quit(_sender, _value):
  app.quit()

quit_button = tree.Button("Quit", theme, on_quit).set_transform(x=1, y=1)
app.add_control(quit_button)

app.run()
tree.deinit()

Runtime Page Switching

Application supports page-style UI switching at runtime.

Methods:

  • register_page(name, controls)
  • show_page(name)
  • clear_controls()

Minimal pattern:

app.register_page("page1", [button_a, list_a])
app.register_page("page2", [back_button])

app.show_page("page1")
app.run()

The demo (PyTREE/Test/demo.py) includes a two-page setup where:

  • Page 1 contains the full UI and a Page 2 button.
  • Page 2 contains a button that returns to page 1.

Notes

  • Navigation between controls is explicit and uses directional links.
  • If an expected navigation path does not work, verify the link direction and whether it is single or double.
  • Input carry-over to the shell after exit is mitigated by flushing pending input on shutdown.

Examples/Guides

Check out the Demo directory for the demo project.

Check out the PyTREE Demo for the Python class-based API and page switching.

Check out the Tutorial Wiki page for a usage guide.

Metadata

Release files for pytre 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytre 1.0.0
File Size Uploaded Provenance Actions
pytre-1.0.0.tar.gz 72.0 kB Without provenance Details for pytre-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytre 1.0.0
File Interpreter ABI Platform Actions
pytre-1.0.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for pytre-1.0.0-cp313-cp313-win_amd64.whl

Total release size: 122.6 kB

Release files / pytre-1.0.0.tar.gz

Download URL pytre-1.0.0.tar.gz
Size 72.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b8c29fbb2c1d86c4f9c7a4d7a390226fe3fc930c4e90955016d7a4e266452eea
BLAKE2b-256 checksum
How to use checksums
c8eaff6c2967e27e7de807797ddd7212d08872da6b5a22781d76a3ddc73beee5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / pytre-1.0.0-cp313-cp313-win_amd64.whl

Download URL pytre-1.0.0-cp313-cp313-win_amd64.whl
Size 50.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
f9800c30fe1bbdb35723368475b3faf17e4ed01f86d8c167d74f017153672d49
BLAKE2b-256 checksum
How to use checksums
390c314acfc65033aea51aeb87d32a8cb55948718d5d4d76cf5fe513501bb5c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Security for pytre 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page