Render C struct / JSON schema as editable PySide6 UI, export to C/JSON/bin
Project description
struct2ui
Render C structs / JSON schemas as an editable PySide6 UI, and convert freely between C / JSON / bin. Built for algorithm parameter tuning: describe a C interface in JSON, auto-generate a Qt form, edit it, then export back to C source, JSON, or binary.
Features
- JSON → UI: describe C structs / enums / arrays with minimal JSON and auto-render Qt widgets (int→QSpinBox, float→QDoubleSpinBox, enum→QComboBox, etc.).
- Embeddable:
StructEditoris a plainQWidgetthat drops into any PySide6 / PyQt UI. - Multi-format export: edited results export to C source, JSON, or binary; C source can also be parsed back into a schema.
- Validation: keyword spell-checking (with “Did you mean X?” hints), semantic audits (
min<=max,step>0), and pipeline cross-validation. - Qt-binding agnostic: built on Qt.py — works with PySide6 / PyQt6 / PySide2 / PyQt5.
Installation
pip install struct2ui
# Pick a Qt binding (choose one)
pip install "struct2ui[pyside6]"
pip install "struct2ui[pyqt6]"
# Enable ELF layout verification (optional)
pip install "struct2ui[elf]"
The library itself only depends on
Qt.py; you must install a Qt binding (PySide6 / PyQt6 / etc.) yourself. ELF verification depends onpyelftools, installed via the[elf]extra.
Quick Start
from Qt import QtWidgets
from struct2ui import StructEditor
app = QtWidgets.QApplication([])
editor = StructEditor(
flow_file="abc.json", # pipeline definition file
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
)
editor.resize(480, 600)
editor.show()
app.exec_()
Embedding into an Existing UI
StructEditor is a regular QWidget; just put it into a layout:
from Qt import QtWidgets
from struct2ui import StructEditor
class MyWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
editor = StructEditor(
"abc.json", "cfg_t",
settings_org="MyCompany", # custom QSettings scope to
settings_app="MyApp", # avoid clashing with the host app
)
self.setCentralWidget(editor)
Constructor Parameters
| Parameter | Description |
|---|---|
flow_file |
Path to the pipeline JSON file (pipeline definition) |
cfg_dir |
Modules directory holding *.json (struct / enum / typedef definitions) |
parent |
Qt parent object, defaults to None |
appearance |
Button appearance overrides, {key: {'mode': ..., 'icon': ..., 'text': ...}} |
settings_org |
QSettings organization name, defaults to 'struct2ui' |
settings_app |
QSettings application name, defaults to 'StructEditor' |
Export API
The low-level export functions can be used standalone, without any UI:
from struct2ui.schema import SchemaRegistry
from struct2ui.exporters import (
emit_c, # sections + registry -> C source string
dumps_json, # -> JSON string
emit_bin, # -> binary bytes
merge_abi, # merge ABI info
verify_sections, # verify .bin layout against an ELF
parse_c_source, # C source -> parse result
build_schema_dict,
)
Architecture
| Layer | Module | Responsibility |
|---|---|---|
| Schema (pure data, no Qt) | struct2ui.schema |
Parse *.json into a Field tree; spell-checking, semantic audits, pipeline cross-validation |
| UI rendering | struct2ui.ui |
WidgetFactory, FormRenderer/TreeRenderer, array tables, when conditional binding |
| Export | struct2ui.exporters |
C / JSON / bin export, C source reverse parsing, ELF verification |
| Top-level widget | struct2ui.StructEditor |
Path bar / action buttons / content area; load report panel; QSettings path memory |
Development
pip install -e ".[dev]" --no-build-isolation
python -m pytest
Tests live under tests/ and drive real Qt widgets headlessly on the offscreen platform.
License
MIT © Jay
Project details
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 struct2ui-0.1.0.tar.gz.
File metadata
- Download URL: struct2ui-0.1.0.tar.gz
- Upload date:
- Size: 71.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7761b9a2dc436f59ebf54ee7bd533dde3d5cda7562d65e6a0b8e3421e22ee649
|
|
| MD5 |
3e35de832611a37e969e70df556ffd38
|
|
| BLAKE2b-256 |
e1501145532bd268aec970bf77e14cec3ee05e8d8064f2e73a6e8b1c9da5beb6
|
File details
Details for the file struct2ui-0.1.0-py3-none-any.whl.
File metadata
- Download URL: struct2ui-0.1.0-py3-none-any.whl
- Upload date:
- Size: 68.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42155cb03a4d64a1cfaaaae9d4fc8ffc4fdf0a483b109e87dfbe22c6c79d20af
|
|
| MD5 |
3731689e89b05668d6884169468240d0
|
|
| BLAKE2b-256 |
e4edceace96d87fc9e3444ee851462890e627aceebec95870f78a4af56c47025
|