Reactive Html Framework - Transform variable relationships into interactive web apps
Project description
RH - Reactive Html Framework
Transform variable relationships into interactive web applications with real-time updates.
Quick Start
from rh import MeshBuilder
# Define relationships between variables
mesh_spec = {
"temp_fahrenheit": ["temp_celsius"],
"temp_kelvin": ["temp_celsius"],
}
# Define how to compute each relationship
functions_spec = {
"temp_fahrenheit": "return temp_celsius * 9/5 + 32;",
"temp_kelvin": "return temp_celsius + 273.15;",
}
# Set initial values
initial_values = {
"temp_celsius": 20.0
}
# Create and build the app
builder = MeshBuilder(mesh_spec, functions_spec, initial_values)
app_path = builder.build_app(title="Temperature Converter")
# Serve it locally
builder.serve(port=8080)
Features
- Bidirectional Dependencies: Variables can depend on each other cyclically
- Real-time Updates: Changes propagate instantly through the mesh
- Convention over Configuration: Smart defaults based on variable names
- Type Inference: Automatic UI widget selection from initial values
- Zero External Dependencies: Works with Python stdlib only
UI Conventions
Variable names automatically determine UI behavior:
initial_values = {
"slider_opacity": 50, # → Range slider (0-100)
"readonly_result": 0, # → Read-only display
"hidden_internal": 10, # → Hidden field
"color_theme": "#ff0000", # → Color picker
"date_created": "2023-01-01" # → Date input
}
Advanced Example
# Physics calculator with custom field overrides
mesh_spec = {
"kinetic_energy": ["mass", "velocity"],
"momentum": ["mass", "velocity"],
"total_energy": ["kinetic_energy", "potential_energy"]
}
functions_spec = {
"kinetic_energy": "return 0.5 * mass * velocity * velocity;",
"momentum": "return mass * velocity;",
"total_energy": "return kinetic_energy + potential_energy;"
}
field_overrides = {
"mass": {
"title": "Mass (kg)",
"minimum": 0.1,
"maximum": 1000,
"ui:help": "Object mass in kilograms"
}
}
builder = MeshBuilder(mesh_spec, functions_spec,
initial_values={"mass": 10, "velocity": 5, "potential_energy": 100},
field_overrides=field_overrides)
Testing
Run the test suite:
python -m pytest tests/
Demo
Try the examples:
python demo.py # Multiple example apps
python example.py # Simple temperature converter with server
License
MIT License - see LICENSE file for details.
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
rh-0.0.7.tar.gz
(16.3 kB
view details)
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
rh-0.0.7-py3-none-any.whl
(11.4 kB
view details)
File details
Details for the file rh-0.0.7.tar.gz.
File metadata
- Download URL: rh-0.0.7.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2a69de71641d90e299f16b3ee50871641debdf30b08ea30b95dccda3a3863b5
|
|
| MD5 |
6ee6754f5a07b3438dfe7d82a43af283
|
|
| BLAKE2b-256 |
73f3b5623b5aa86f5feb025b92d3edb401b63c1e13a1ac9ecef24909580eae47
|
File details
Details for the file rh-0.0.7-py3-none-any.whl.
File metadata
- Download URL: rh-0.0.7-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3cbcc1d8b47ada59f77c5473e1aa34d7b7864fc3a4a3613df3193356c0573bf
|
|
| MD5 |
18da75e9e831757f8bc5d3dd30c3f4d2
|
|
| BLAKE2b-256 |
24695b2dabd86fd89eb23a9d6660829c9c38add34513006b06f27785dff9ac23
|