LogicWeave allows you to compile your Python scripts into Wheels (.whl). This allows you to define custom inputs (sliders, text fields) and outputs for the Web IDE.
1. Project Structure
Your project folder should look like this. The package name (e.g., logicweave_test) must match your configuration.
my-project/
├── pyproject.toml # Build configuration
└── logicweave_test/ # Source folder
├── __init__.py # (Empty file)
├── main.py # Logic code
└── config.json # UI definition
2. Configuration (pyproject.toml)
This file tells the builder how to package your code.
Crucial: You must define the entry-point so the Web IDE knows which function to run.
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "logicweave-test"
version = "0.1.0"
description = "A test wheel for the LogicWeave IDE"
requires-python = ">=3.7"
dependencies = []
[tool.setuptools]
packages = ["logicweave_test"]
include-package-data = true
# This ensures config.json is bundled with the code
[tool.setuptools.package-data]
logicweave_test = ["config.json"]
# ENTRY POINT: Maps 'app' to the 'run' function in main.py
[project.entry-points."logicweave.plugins"]
app = "logicweave_test.main:run"
3. UI Definition (config.json)
Define inputs (sent to your script) and outputs (displayed in the IDE).
- usage "input": Creates UI controls (sliders, inputs) passed to your
run() function.
- usage "output": Creates display widgets updated via
lw.log().
[
{
"key": "blink_speed",
"label": "Blink Speed (s)",
"type": "float",
"default": 0.5,
"step": 0.1,
"max": 10,
"min": 0.1,
"usage": "input"
},
{
"key": "led_state",
"label": "Live LED Status",
"type": "text",
"default": "OFF",
"usage": "output"
}
]
4. Logic (main.py)
Your script must accept a config dictionary.
The function lw.log(key, value) is automatically injected by the runner to update the Web UI.
import time
from LogicWeave import LogicWeave
def run(config=None):
# 1. Get Inputs from Web UI
blink_speed = float(config.get("blink_speed", 0.5))
loop_count = int(config.get("loop_count", 5))
print(f"▶️ Starting Run: {blink_speed}s interval")
with LogicWeave() as lw:
led = lw.gpio(25)
led.set_function(7)
state = False
for i in range(loop_count * 2):
state = not state
led.write(state)
# 2. Send Data back to Web UI
stateStr = 'ON' if state else 'OFF'
lw.log("led_state", stateStr)
time.sleep(blink_speed)
print("✅ Script Finished.")
5. Build & Upload
Open your terminal in the project folder and run:
pip install build
python -m build
This will generate a .whl file in the dist/ folder. Upload this file to the LogicWeave Web IDE to run your plugin.