struct2ui 0.2.0__tar.gz → 0.4.0__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.
Files changed (45) hide show
  1. {struct2ui-0.2.0/src/struct2ui.egg-info → struct2ui-0.4.0}/PKG-INFO +59 -3
  2. {struct2ui-0.2.0 → struct2ui-0.4.0}/README.md +58 -2
  3. {struct2ui-0.2.0 → struct2ui-0.4.0}/pyproject.toml +1 -1
  4. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/__init__.py +1 -1
  5. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/editor.py +355 -70
  6. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/ui/widgets.py +42 -0
  7. {struct2ui-0.2.0 → struct2ui-0.4.0/src/struct2ui.egg-info}/PKG-INFO +59 -3
  8. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_editor.py +110 -8
  9. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_save.py +72 -9
  10. {struct2ui-0.2.0 → struct2ui-0.4.0}/LICENSE +0 -0
  11. {struct2ui-0.2.0 → struct2ui-0.4.0}/setup.cfg +0 -0
  12. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/exporters/__init__.py +0 -0
  13. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/exporters/bin_emitter.py +0 -0
  14. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/exporters/c_emitter.py +0 -0
  15. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/exporters/c_parser.py +0 -0
  16. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/exporters/elf_verifier.py +0 -0
  17. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/exporters/json_format.py +0 -0
  18. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/c2j.png +0 -0
  19. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/elf.png +0 -0
  20. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/export_notes_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
  21. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/flowchart_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
  22. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/refresh_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
  23. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/report_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
  24. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/save_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
  25. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/save_as_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
  26. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/settings_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
  27. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/icons/widgets_24dp_000000_FILL0_wght400_GRAD0_opsz24.png +0 -0
  28. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/schema.py +0 -0
  29. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/ui/__init__.py +0 -0
  30. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/ui/renderers.py +0 -0
  31. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui/ui/tables.py +0 -0
  32. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui.egg-info/SOURCES.txt +0 -0
  33. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui.egg-info/dependency_links.txt +0 -0
  34. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui.egg-info/requires.txt +0 -0
  35. {struct2ui-0.2.0 → struct2ui-0.4.0}/src/struct2ui.egg-info/top_level.txt +0 -0
  36. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_bin_emitter.py +0 -0
  37. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_c_emitter.py +0 -0
  38. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_c_parser.py +0 -0
  39. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_choices.py +0 -0
  40. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_elf_verifier.py +0 -0
  41. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_float_precision.py +0 -0
  42. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_int_checkbox.py +0 -0
  43. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_json_format.py +0 -0
  44. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_load_report.py +0 -0
  45. {struct2ui-0.2.0 → struct2ui-0.4.0}/tests/test_value_readback.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: struct2ui
3
- Version: 0.2.0
3
+ Version: 0.4.0
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
@@ -260,11 +260,67 @@ class MyWindow(QtWidgets.QMainWindow):
260
260
  | --- | --- |
261
261
  | `flow_file` | Path to the pipeline JSON file (pipeline definition), defaults to `None`; pick it in the UI when omitted |
262
262
  | `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions), defaults to `None`; pick it in the UI when omitted |
263
+ | `elf_file` | Path to an ELF for layout verification, defaults to `None`; pick it under Settings when omitted. The enable checkbox there toggles verification on/off while keeping the path. |
263
264
  | `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
265
  | `appearance` | Button appearance overrides, `{key: {'mode': ..., 'icon': ..., 'text': ...}}` |
266
266
  | `settings_org` | QSettings organization name, defaults to `'struct2ui'` |
267
267
  | `settings_app` | QSettings application name, defaults to `'StructEditor'` |
268
+ | `toolbar_orientation` | Toolbar layout, `'horizontal'` (default) or `'vertical'` |
269
+ | `custom_button_position` | Where `add_custom_button()` drops buttons relative to the built-ins: `'end'` (after, default) or `'start'` (before / far left) |
270
+
271
+ ## Custom Toolbar Buttons
272
+
273
+ Host applications can add their own buttons to the top path bar via
274
+ `add_custom_button()`. All custom buttons form a single group, separated from
275
+ the built-in buttons by a divider that is added automatically — you only choose
276
+ which side they sit on (once, via the `custom_button_position` constructor arg).
277
+
278
+ ```python
279
+ editor = StructEditor("abc.json", "cfg_t", custom_button_position="end")
280
+
281
+ def on_send():
282
+ print(editor.current_values())
283
+
284
+ btn = editor.add_custom_button(
285
+ "Send", # tooltip / accessible label (shown when no icon)
286
+ on_send, # callable invoked on click (no arguments)
287
+ icon="icons/send.png", # optional; falls back to text when missing
288
+ checkable=False, # optional; make the button toggleable
289
+ )
290
+ # `btn` is the created QPushButton, returned so you can tweak it further.
291
+ ```
292
+
293
+ | Parameter | Description |
294
+ | --- | --- |
295
+ | `text` | Tooltip / accessible label, also shown when no icon is given. **Required.** |
296
+ | `on_click` | Callable invoked on click, takes no arguments. **Required.** |
297
+ | `icon` | Path to an icon file; falls back to `text` when the path is missing/empty. |
298
+ | `checkable` | Make the button toggleable, defaults to `False`. |
299
+
300
+ Returns the created `QPushButton`.
301
+
302
+ ## Programmatic API
303
+
304
+ Beyond the UI, `StructEditor` exposes methods to read state and drive exports
305
+ from code (e.g. wired to a custom button):
306
+
307
+ | Method | Description |
308
+ | --- | --- |
309
+ | `current_values() -> dict` | Live editor values of the active section, keyed by field name (empty dict when no parameter section is shown). |
310
+ | `current_paths() -> dict` | Current `{'modules', 'pipeline', 'elf'}` file paths; an empty string means that slot is unset. |
311
+ | `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
+
313
+ `export_bin` verifies the ELF layout first when an ELF is selected and enabled (the file is
314
+ still written, matching the UI flow). With `show_dialogs=True` it pops the same
315
+ success / ELF-mismatch / failure dialogs the UI shows; with the default
316
+ `show_dialogs=False` no dialogs appear and render/write failures are raised as
317
+ exceptions for the caller to handle.
318
+
319
+ ```python
320
+ paths = editor.current_paths() # {'modules': ..., 'pipeline': ..., 'elf': ...}
321
+ name = paths['pipeline'] # derive an output name from the pipeline
322
+ ok = editor.export_bin("out/speech.bin") # True when ELF layout is clean
323
+ ```
268
324
 
269
325
  ## Export API
270
326
 
@@ -290,7 +346,7 @@ from struct2ui.exporters import (
290
346
  | Schema (pure data, no Qt) | `struct2ui.schema` | Parse `*.json` into a Field tree; spell-checking, semantic audits, pipeline cross-validation |
291
347
  | UI rendering | `struct2ui.ui` | `WidgetFactory`, `FormRenderer`/`TreeRenderer`, array tables, `when` conditional binding |
292
348
  | Export | `struct2ui.exporters` | C / JSON / bin export, C source reverse parsing, ELF verification |
293
- | Top-level widget | `struct2ui.StructEditor` | Path bar / action buttons / content area; load report panel; QSettings path memory |
349
+ | Top-level widget | `struct2ui.StructEditor` | Action toolbar / content area; Settings panel for source paths; load report panel; QSettings path memory |
294
350
 
295
351
  ## Development
296
352
 
@@ -207,11 +207,67 @@ class MyWindow(QtWidgets.QMainWindow):
207
207
  | --- | --- |
208
208
  | `flow_file` | Path to the pipeline JSON file (pipeline definition), defaults to `None`; pick it in the UI when omitted |
209
209
  | `cfg_dir` | Modules directory holding `*.json` (struct / enum / typedef definitions), defaults to `None`; pick it in the UI when omitted |
210
+ | `elf_file` | Path to an ELF for layout verification, defaults to `None`; pick it under Settings when omitted. The enable checkbox there toggles verification on/off while keeping the path. |
210
211
  | `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
212
  | `appearance` | Button appearance overrides, `{key: {'mode': ..., 'icon': ..., 'text': ...}}` |
213
213
  | `settings_org` | QSettings organization name, defaults to `'struct2ui'` |
214
214
  | `settings_app` | QSettings application name, defaults to `'StructEditor'` |
215
+ | `toolbar_orientation` | Toolbar layout, `'horizontal'` (default) or `'vertical'` |
216
+ | `custom_button_position` | Where `add_custom_button()` drops buttons relative to the built-ins: `'end'` (after, default) or `'start'` (before / far left) |
217
+
218
+ ## Custom Toolbar Buttons
219
+
220
+ Host applications can add their own buttons to the top path bar via
221
+ `add_custom_button()`. All custom buttons form a single group, separated from
222
+ the built-in buttons by a divider that is added automatically — you only choose
223
+ which side they sit on (once, via the `custom_button_position` constructor arg).
224
+
225
+ ```python
226
+ editor = StructEditor("abc.json", "cfg_t", custom_button_position="end")
227
+
228
+ def on_send():
229
+ print(editor.current_values())
230
+
231
+ btn = editor.add_custom_button(
232
+ "Send", # tooltip / accessible label (shown when no icon)
233
+ on_send, # callable invoked on click (no arguments)
234
+ icon="icons/send.png", # optional; falls back to text when missing
235
+ checkable=False, # optional; make the button toggleable
236
+ )
237
+ # `btn` is the created QPushButton, returned so you can tweak it further.
238
+ ```
239
+
240
+ | Parameter | Description |
241
+ | --- | --- |
242
+ | `text` | Tooltip / accessible label, also shown when no icon is given. **Required.** |
243
+ | `on_click` | Callable invoked on click, takes no arguments. **Required.** |
244
+ | `icon` | Path to an icon file; falls back to `text` when the path is missing/empty. |
245
+ | `checkable` | Make the button toggleable, defaults to `False`. |
246
+
247
+ Returns the created `QPushButton`.
248
+
249
+ ## Programmatic API
250
+
251
+ Beyond the UI, `StructEditor` exposes methods to read state and drive exports
252
+ from code (e.g. wired to a custom button):
253
+
254
+ | Method | Description |
255
+ | --- | --- |
256
+ | `current_values() -> dict` | Live editor values of the active section, keyed by field name (empty dict when no parameter section is shown). |
257
+ | `current_paths() -> dict` | Current `{'modules', 'pipeline', 'elf'}` file paths; an empty string means that slot is unset. |
258
+ | `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
+
260
+ `export_bin` verifies the ELF layout first when an ELF is selected and enabled (the file is
261
+ still written, matching the UI flow). With `show_dialogs=True` it pops the same
262
+ success / ELF-mismatch / failure dialogs the UI shows; with the default
263
+ `show_dialogs=False` no dialogs appear and render/write failures are raised as
264
+ exceptions for the caller to handle.
265
+
266
+ ```python
267
+ paths = editor.current_paths() # {'modules': ..., 'pipeline': ..., 'elf': ...}
268
+ name = paths['pipeline'] # derive an output name from the pipeline
269
+ ok = editor.export_bin("out/speech.bin") # True when ELF layout is clean
270
+ ```
215
271
 
216
272
  ## Export API
217
273
 
@@ -237,7 +293,7 @@ from struct2ui.exporters import (
237
293
  | Schema (pure data, no Qt) | `struct2ui.schema` | Parse `*.json` into a Field tree; spell-checking, semantic audits, pipeline cross-validation |
238
294
  | UI rendering | `struct2ui.ui` | `WidgetFactory`, `FormRenderer`/`TreeRenderer`, array tables, `when` conditional binding |
239
295
  | Export | `struct2ui.exporters` | C / JSON / bin export, C source reverse parsing, ELF verification |
240
- | Top-level widget | `struct2ui.StructEditor` | Path bar / action buttons / content area; load report panel; QSettings path memory |
296
+ | Top-level widget | `struct2ui.StructEditor` | Action toolbar / content area; Settings panel for source paths; load report panel; QSettings path memory |
241
297
 
242
298
  ## Development
243
299
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "struct2ui"
7
- version = "0.2.0"
7
+ version = "0.4.0"
8
8
  description = "Render C struct / JSON schema as editable PySide6 UI, export to C/JSON/bin"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,4 +1,4 @@
1
1
  from .editor import StructEditor
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.4.0"
4
4
  __all__ = ["StructEditor"]