struct2ui 0.3.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {struct2ui-0.3.0/src/struct2ui.egg-info → struct2ui-0.4.1}/PKG-INFO +45 -19
- {struct2ui-0.3.0 → struct2ui-0.4.1}/README.md +44 -18
- {struct2ui-0.3.0 → struct2ui-0.4.1}/pyproject.toml +1 -1
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/__init__.py +1 -1
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/editor.py +237 -91
- {struct2ui-0.3.0 → struct2ui-0.4.1/src/struct2ui.egg-info}/PKG-INFO +45 -19
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_editor.py +71 -66
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_load_report.py +12 -11
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_save.py +62 -57
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_value_readback.py +2 -3
- {struct2ui-0.3.0 → struct2ui-0.4.1}/LICENSE +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/setup.cfg +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/exporters/__init__.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/exporters/bin_emitter.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/exporters/c_emitter.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/exporters/c_parser.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/exporters/elf_verifier.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/exporters/json_format.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/c2j.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/elf.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/export_notes_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/flowchart_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/refresh_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/report_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/save_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/save_as_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/settings_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/icons/widgets_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/schema.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/ui/__init__.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/ui/renderers.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/ui/tables.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui/ui/widgets.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui.egg-info/SOURCES.txt +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui.egg-info/dependency_links.txt +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui.egg-info/requires.txt +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/src/struct2ui.egg-info/top_level.txt +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_bin_emitter.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_c_emitter.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_c_parser.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_choices.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_elf_verifier.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_float_precision.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_int_checkbox.py +0 -0
- {struct2ui-0.3.0 → struct2ui-0.4.1}/tests/test_json_format.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: struct2ui
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Render C struct / JSON schema as editable PySide6 UI, export to C/JSON/bin
|
|
5
5
|
Author: Jay
|
|
6
6
|
License: MIT License
|
|
@@ -87,9 +87,10 @@ from struct2ui import StructEditor
|
|
|
87
87
|
|
|
88
88
|
app = QtWidgets.QApplication([])
|
|
89
89
|
|
|
90
|
-
editor = StructEditor(
|
|
91
|
-
|
|
92
|
-
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
|
|
90
|
+
editor = StructEditor()
|
|
91
|
+
editor.set_sources(
|
|
92
|
+
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
|
|
93
|
+
flow_file="abc.json", # pipeline definition file
|
|
93
94
|
)
|
|
94
95
|
editor.resize(480, 600)
|
|
95
96
|
editor.show()
|
|
@@ -246,28 +247,48 @@ from struct2ui import StructEditor
|
|
|
246
247
|
class MyWindow(QtWidgets.QMainWindow):
|
|
247
248
|
def __init__(self):
|
|
248
249
|
super().__init__()
|
|
249
|
-
editor = StructEditor(
|
|
250
|
-
|
|
251
|
-
settings_org="MyCompany", # custom QSettings scope to
|
|
252
|
-
settings_app="MyApp", # avoid clashing with the host app
|
|
253
|
-
)
|
|
250
|
+
editor = StructEditor()
|
|
251
|
+
editor.set_sources(cfg_dir="cfg_t", flow_file="abc.json")
|
|
254
252
|
self.setCentralWidget(editor)
|
|
255
253
|
```
|
|
256
254
|
|
|
255
|
+
`StructEditor` takes no source paths at construction time and keeps no
|
|
256
|
+
persistent state of its own. Point it at its sources after creating it with
|
|
257
|
+
`set_sources()` (or let the user pick them at runtime via Settings). If you
|
|
258
|
+
want to remember the last-used paths across runs, store them in the host app
|
|
259
|
+
and call `set_sources()` again at startup.
|
|
260
|
+
|
|
257
261
|
### Constructor Parameters
|
|
258
262
|
|
|
259
263
|
| Parameter | Description |
|
|
260
264
|
| --- | --- |
|
|
261
|
-
| `flow_file` | Path to the pipeline JSON file (pipeline definition), defaults to `None`; pick it in the UI when omitted |
|
|
262
|
-
| `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions), defaults to `None`; pick it in the UI when omitted |
|
|
263
265
|
| `parent` | Qt parent object, defaults to `None` |
|
|
264
|
-
| `elf_path` | Path to an ELF for layout verification, defaults to `None`; pick it in the UI when omitted |
|
|
265
266
|
| `appearance` | Button appearance overrides, `{key: {'mode': ..., 'icon': ..., 'text': ...}}` |
|
|
266
|
-
| `settings_org` | QSettings organization name, defaults to `'struct2ui'` |
|
|
267
|
-
| `settings_app` | QSettings application name, defaults to `'StructEditor'` |
|
|
268
|
-
| `toolbar_orientation` | Toolbar layout, `'horizontal'` (default) or `'vertical'` |
|
|
269
267
|
| `custom_button_position` | Where `add_custom_button()` drops buttons relative to the built-ins: `'end'` (after, default) or `'start'` (before / far left) |
|
|
270
268
|
|
|
269
|
+
### Setting Sources
|
|
270
|
+
|
|
271
|
+
Source paths are configured after construction, not passed to the constructor.
|
|
272
|
+
Omitting an argument leaves that slot untouched.
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
editor.set_sources(
|
|
276
|
+
cfg_dir="cfg_t", # modules dir: *.json with struct/enum/typedef defs
|
|
277
|
+
flow_file="abc.json", # pipeline definition file
|
|
278
|
+
elf_file="fw.elf", # optional ELF for .bin layout verification
|
|
279
|
+
)
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
| `set_sources` argument | Description |
|
|
283
|
+
| --- | --- |
|
|
284
|
+
| `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions) |
|
|
285
|
+
| `flow_file` | Path to the pipeline JSON file (pipeline definition) |
|
|
286
|
+
| `elf_file` | Path to an ELF for `.bin` layout verification; setting it enables verification (toggle later via the Settings checkbox, which keeps the path) |
|
|
287
|
+
| `elf_enabled` | Override whether ELF verification runs, independent of whether a path is set |
|
|
288
|
+
| `reload` | Rebuild schema / flow / UI from the new sources, defaults to `True` |
|
|
289
|
+
|
|
290
|
+
Toolbar orientation is set with `set_flow_orientation('horizontal' | 'vertical')`.
|
|
291
|
+
|
|
271
292
|
## Custom Toolbar Buttons
|
|
272
293
|
|
|
273
294
|
Host applications can add their own buttons to the top path bar via
|
|
@@ -276,7 +297,8 @@ the built-in buttons by a divider that is added automatically — you only choos
|
|
|
276
297
|
which side they sit on (once, via the `custom_button_position` constructor arg).
|
|
277
298
|
|
|
278
299
|
```python
|
|
279
|
-
editor = StructEditor(
|
|
300
|
+
editor = StructEditor(custom_button_position="end")
|
|
301
|
+
editor.set_sources(cfg_dir="cfg_t", flow_file="abc.json")
|
|
280
302
|
|
|
281
303
|
def on_send():
|
|
282
304
|
print(editor.current_values())
|
|
@@ -306,11 +328,15 @@ from code (e.g. wired to a custom button):
|
|
|
306
328
|
|
|
307
329
|
| Method | Description |
|
|
308
330
|
| --- | --- |
|
|
331
|
+
| `set_sources(cfg_dir=None, flow_file=None, elf_file=None, elf_enabled=None, reload=True)` | Point the editor at its source files after construction. See [Setting Sources](#setting-sources). |
|
|
332
|
+
| `set_flow_orientation(orientation)` | Switch the flow-button strip between `'horizontal'` (top, default) and `'vertical'` (left). Rebuilds the strip and keeps the active stage selected. |
|
|
333
|
+
| `show_section(label) -> None` | Open the stage/section named `label` in the content area (the same as clicking its flow button). Paints the error panel instead when that stage has pipeline errors; clears the content when the label is unknown. |
|
|
309
334
|
| `current_values() -> dict` | Live editor values of the active section, keyed by field name (empty dict when no parameter section is shown). |
|
|
310
335
|
| `current_paths() -> dict` | Current `{'modules', 'pipeline', 'elf'}` file paths; an empty string means that slot is unset. |
|
|
311
|
-
| `
|
|
336
|
+
| `add_custom_button(text, on_click, icon=None, checkable=False) -> QPushButton` | Add a host button to the top path bar. See [Custom Toolbar Buttons](#custom-toolbar-buttons). |
|
|
337
|
+
| `export_bin(path, show_dialogs=False) -> bool` | Write the current pipeline to a `.bin` at `path` — the programmatic equivalent of clicking Export → Binary. Returns `True` when there are no ELF layout errors (or ELF verification is off), `False` otherwise. |
|
|
312
338
|
|
|
313
|
-
`export_bin` verifies the ELF layout first when an ELF is selected (the file is
|
|
339
|
+
`export_bin` verifies the ELF layout first when an ELF is selected and enabled (the file is
|
|
314
340
|
still written, matching the UI flow). With `show_dialogs=True` it pops the same
|
|
315
341
|
success / ELF-mismatch / failure dialogs the UI shows; with the default
|
|
316
342
|
`show_dialogs=False` no dialogs appear and render/write failures are raised as
|
|
@@ -346,7 +372,7 @@ from struct2ui.exporters import (
|
|
|
346
372
|
| Schema (pure data, no Qt) | `struct2ui.schema` | Parse `*.json` into a Field tree; spell-checking, semantic audits, pipeline cross-validation |
|
|
347
373
|
| UI rendering | `struct2ui.ui` | `WidgetFactory`, `FormRenderer`/`TreeRenderer`, array tables, `when` conditional binding |
|
|
348
374
|
| Export | `struct2ui.exporters` | C / JSON / bin export, C source reverse parsing, ELF verification |
|
|
349
|
-
| Top-level widget | `struct2ui.StructEditor` |
|
|
375
|
+
| Top-level widget | `struct2ui.StructEditor` | Action toolbar / content area; Settings panel for source paths; load report panel |
|
|
350
376
|
|
|
351
377
|
## Development
|
|
352
378
|
|
|
@@ -34,9 +34,10 @@ from struct2ui import StructEditor
|
|
|
34
34
|
|
|
35
35
|
app = QtWidgets.QApplication([])
|
|
36
36
|
|
|
37
|
-
editor = StructEditor(
|
|
38
|
-
|
|
39
|
-
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
|
|
37
|
+
editor = StructEditor()
|
|
38
|
+
editor.set_sources(
|
|
39
|
+
cfg_dir="cfg_t", # modules dir: *.json holding struct/enum/typedef
|
|
40
|
+
flow_file="abc.json", # pipeline definition file
|
|
40
41
|
)
|
|
41
42
|
editor.resize(480, 600)
|
|
42
43
|
editor.show()
|
|
@@ -193,28 +194,48 @@ from struct2ui import StructEditor
|
|
|
193
194
|
class MyWindow(QtWidgets.QMainWindow):
|
|
194
195
|
def __init__(self):
|
|
195
196
|
super().__init__()
|
|
196
|
-
editor = StructEditor(
|
|
197
|
-
|
|
198
|
-
settings_org="MyCompany", # custom QSettings scope to
|
|
199
|
-
settings_app="MyApp", # avoid clashing with the host app
|
|
200
|
-
)
|
|
197
|
+
editor = StructEditor()
|
|
198
|
+
editor.set_sources(cfg_dir="cfg_t", flow_file="abc.json")
|
|
201
199
|
self.setCentralWidget(editor)
|
|
202
200
|
```
|
|
203
201
|
|
|
202
|
+
`StructEditor` takes no source paths at construction time and keeps no
|
|
203
|
+
persistent state of its own. Point it at its sources after creating it with
|
|
204
|
+
`set_sources()` (or let the user pick them at runtime via Settings). If you
|
|
205
|
+
want to remember the last-used paths across runs, store them in the host app
|
|
206
|
+
and call `set_sources()` again at startup.
|
|
207
|
+
|
|
204
208
|
### Constructor Parameters
|
|
205
209
|
|
|
206
210
|
| Parameter | Description |
|
|
207
211
|
| --- | --- |
|
|
208
|
-
| `flow_file` | Path to the pipeline JSON file (pipeline definition), defaults to `None`; pick it in the UI when omitted |
|
|
209
|
-
| `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions), defaults to `None`; pick it in the UI when omitted |
|
|
210
212
|
| `parent` | Qt parent object, defaults to `None` |
|
|
211
|
-
| `elf_path` | Path to an ELF for layout verification, defaults to `None`; pick it in the UI when omitted |
|
|
212
213
|
| `appearance` | Button appearance overrides, `{key: {'mode': ..., 'icon': ..., 'text': ...}}` |
|
|
213
|
-
| `settings_org` | QSettings organization name, defaults to `'struct2ui'` |
|
|
214
|
-
| `settings_app` | QSettings application name, defaults to `'StructEditor'` |
|
|
215
|
-
| `toolbar_orientation` | Toolbar layout, `'horizontal'` (default) or `'vertical'` |
|
|
216
214
|
| `custom_button_position` | Where `add_custom_button()` drops buttons relative to the built-ins: `'end'` (after, default) or `'start'` (before / far left) |
|
|
217
215
|
|
|
216
|
+
### Setting Sources
|
|
217
|
+
|
|
218
|
+
Source paths are configured after construction, not passed to the constructor.
|
|
219
|
+
Omitting an argument leaves that slot untouched.
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
editor.set_sources(
|
|
223
|
+
cfg_dir="cfg_t", # modules dir: *.json with struct/enum/typedef defs
|
|
224
|
+
flow_file="abc.json", # pipeline definition file
|
|
225
|
+
elf_file="fw.elf", # optional ELF for .bin layout verification
|
|
226
|
+
)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
| `set_sources` argument | Description |
|
|
230
|
+
| --- | --- |
|
|
231
|
+
| `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions) |
|
|
232
|
+
| `flow_file` | Path to the pipeline JSON file (pipeline definition) |
|
|
233
|
+
| `elf_file` | Path to an ELF for `.bin` layout verification; setting it enables verification (toggle later via the Settings checkbox, which keeps the path) |
|
|
234
|
+
| `elf_enabled` | Override whether ELF verification runs, independent of whether a path is set |
|
|
235
|
+
| `reload` | Rebuild schema / flow / UI from the new sources, defaults to `True` |
|
|
236
|
+
|
|
237
|
+
Toolbar orientation is set with `set_flow_orientation('horizontal' | 'vertical')`.
|
|
238
|
+
|
|
218
239
|
## Custom Toolbar Buttons
|
|
219
240
|
|
|
220
241
|
Host applications can add their own buttons to the top path bar via
|
|
@@ -223,7 +244,8 @@ the built-in buttons by a divider that is added automatically — you only choos
|
|
|
223
244
|
which side they sit on (once, via the `custom_button_position` constructor arg).
|
|
224
245
|
|
|
225
246
|
```python
|
|
226
|
-
editor = StructEditor(
|
|
247
|
+
editor = StructEditor(custom_button_position="end")
|
|
248
|
+
editor.set_sources(cfg_dir="cfg_t", flow_file="abc.json")
|
|
227
249
|
|
|
228
250
|
def on_send():
|
|
229
251
|
print(editor.current_values())
|
|
@@ -253,11 +275,15 @@ from code (e.g. wired to a custom button):
|
|
|
253
275
|
|
|
254
276
|
| Method | Description |
|
|
255
277
|
| --- | --- |
|
|
278
|
+
| `set_sources(cfg_dir=None, flow_file=None, elf_file=None, elf_enabled=None, reload=True)` | Point the editor at its source files after construction. See [Setting Sources](#setting-sources). |
|
|
279
|
+
| `set_flow_orientation(orientation)` | Switch the flow-button strip between `'horizontal'` (top, default) and `'vertical'` (left). Rebuilds the strip and keeps the active stage selected. |
|
|
280
|
+
| `show_section(label) -> None` | Open the stage/section named `label` in the content area (the same as clicking its flow button). Paints the error panel instead when that stage has pipeline errors; clears the content when the label is unknown. |
|
|
256
281
|
| `current_values() -> dict` | Live editor values of the active section, keyed by field name (empty dict when no parameter section is shown). |
|
|
257
282
|
| `current_paths() -> dict` | Current `{'modules', 'pipeline', 'elf'}` file paths; an empty string means that slot is unset. |
|
|
258
|
-
| `
|
|
283
|
+
| `add_custom_button(text, on_click, icon=None, checkable=False) -> QPushButton` | Add a host button to the top path bar. See [Custom Toolbar Buttons](#custom-toolbar-buttons). |
|
|
284
|
+
| `export_bin(path, show_dialogs=False) -> bool` | Write the current pipeline to a `.bin` at `path` — the programmatic equivalent of clicking Export → Binary. Returns `True` when there are no ELF layout errors (or ELF verification is off), `False` otherwise. |
|
|
259
285
|
|
|
260
|
-
`export_bin` verifies the ELF layout first when an ELF is selected (the file is
|
|
286
|
+
`export_bin` verifies the ELF layout first when an ELF is selected and enabled (the file is
|
|
261
287
|
still written, matching the UI flow). With `show_dialogs=True` it pops the same
|
|
262
288
|
success / ELF-mismatch / failure dialogs the UI shows; with the default
|
|
263
289
|
`show_dialogs=False` no dialogs appear and render/write failures are raised as
|
|
@@ -293,7 +319,7 @@ from struct2ui.exporters import (
|
|
|
293
319
|
| Schema (pure data, no Qt) | `struct2ui.schema` | Parse `*.json` into a Field tree; spell-checking, semantic audits, pipeline cross-validation |
|
|
294
320
|
| UI rendering | `struct2ui.ui` | `WidgetFactory`, `FormRenderer`/`TreeRenderer`, array tables, `when` conditional binding |
|
|
295
321
|
| Export | `struct2ui.exporters` | C / JSON / bin export, C source reverse parsing, ELF verification |
|
|
296
|
-
| Top-level widget | `struct2ui.StructEditor` |
|
|
322
|
+
| Top-level widget | `struct2ui.StructEditor` | Action toolbar / content area; Settings panel for source paths; load report panel |
|
|
297
323
|
|
|
298
324
|
## Development
|
|
299
325
|
|