Python bindings for Terminal Rendering EnginE (TREE)
Project description
Terminal Rendering EnginE (TREE)
A rendering engine for a terminal.
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:
- Add the header and source file directly to your project.
- Build TREE, and link it to your program.
C Library Build Scripts
TREE/Source/devenv.bat build releaseTREE/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:
- Open a terminal in
PyTREE/Source. - Run
devenv.bat build.
Notes:
- The script auto-builds TREE Release dependency if
TREE.libis 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:
- Open a terminal in
PyTREE/Test. - Run
python demo.py.
PyPI Packaging and Publishing
Packaging files live in PyTREE/Source:
setup.pypyproject.tomlMANIFEST.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.0to 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
xclipbeing available. - macOS support is not enabled yet in CI, but can be added with a
macos-latestrunner.
Python API (OO Wrapper)
The recommended Python surface is class-based and uses the C extension under the hood.
Core classes:
ThemeApplicationButton,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 2button. - 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytre-1.0.0.tar.gz.
File metadata
- Download URL: pytre-1.0.0.tar.gz
- Upload date:
- Size: 72.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8c29fbb2c1d86c4f9c7a4d7a390226fe3fc930c4e90955016d7a4e266452eea
|
|
| MD5 |
ddc98b9336bc59667c272d4f5b057008
|
|
| BLAKE2b-256 |
c8eaff6c2967e27e7de807797ddd7212d08872da6b5a22781d76a3ddc73beee5
|
File details
Details for the file pytre-1.0.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: pytre-1.0.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 50.6 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9800c30fe1bbdb35723368475b3faf17e4ed01f86d8c167d74f017153672d49
|
|
| MD5 |
9da8d3e275faeabf5a8efbb6fcc6cb14
|
|
| BLAKE2b-256 |
390c314acfc65033aea51aeb87d32a8cb55948718d5d4d76cf5fe513501bb5c2
|