Python binding for nil/xit: C++ bridge to frontend with frames, values, and signals
Project description
nil-xit Python Binding
Python binding for nil/xit – a C++ bridge that connects backends to frontend UIs with a tiny, explicit protocol.
Define frames, values, and signals in C++; interact with them from Python. The client can be web, desktop, or any runtime that speaks the protocol.
Features
- Frames – Group values and signals displayed by a UI component
- Two flavors – Unique (one instance) and tagged (keyed by a tag)
- Values – Bidirectional data binding with buffer types (bytes)
- Signals – Events from UI to backend with optional byte payloads
Installation
pip install nil-xit
Quick Start
import nil_xit
import nil_service
# Create HTTP server on 127.0.0.1:1101
http = nil_service.create_http_server("127.0.0.1", 1101, 100 * 1024 * 1024)
# Setup server with asset paths
nil_xit.setup_server(http, ["assets"])
# Create websocket event service
ws = http.use_ws("/ws")
# Create core from web service and websocket event
core = nil_xit.create_core(http, ws)
# Add a frame
frame = core.add_unique_frame("index", "$base/gui/Demo.svelte")
# Add a value with getter and setter (buffer type)
def encode_value() -> bytes:
return b"hello world"
def decode_value(data: bytes) -> None:
print(f"value changed: {data.decode('utf-8')}")
value = frame.add_value("my_value", encode_value, decode_value)
# Add a signal handler
def on_button_click() -> None:
print("Button clicked!")
value.post(b"updated value")
frame.add_signal("click", on_button_click)
# Main loop
while True:
http.poll()
For a complete example, see sandbox/main.py.
Supported Types
The Python binding supports buffer types only:
bytes– Binary data passed asbuffer_type<T>in C++- Values use getter/setter functions that work with bytes
- Signals pass optional byte payloads
Architecture
The Python binding wraps the C API (libnil-xit-c-api.so) which provides access to:
- unique frames – Single-instance UI components
- tagged frames – Multi-instance UI components (keyed by tag)
- values – Bidirectional data binding with buffer types
- signals – Events from UI to backend with optional byte payloads
Documentation
For detailed API documentation and more examples, visit:
License
CC BY-NC-ND 4.0
Support
For issues, questions, or contributions, visit the GitHub repository.
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 Distributions
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 nil_xit-0.3.10rc2-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: nil_xit-0.3.10rc2-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 106.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff4be50f82868838fe6abcc21b37f7db15169a9979617feace0d57ba0b665fd7
|
|
| MD5 |
fbf7abdcf70e5e2082ab96d069c5acdc
|
|
| BLAKE2b-256 |
876fcb303f9abca09b6971267477251c55c82b813956abc95dbf4bbd2ba5d334
|