Structural Bioinformatics Library
Template C++ / Python API for developping structural bioinformatics applications.
SBL.gui_ui2json Namespace Reference

Packages

Build structured GUI JSON specifications from Qt Designer `.ui` files and
command-line interface (CLI) descriptions.

This module implements the "UI-to-Spec" stage of the SBL GUI generation pipeline.
It translates visual widget layouts from Qt Designer and semantic CLI metadata
into a reproducible, framework-agnostic JSON specification.

Three primary utilities are provided:

* `UiToJsonConverter`
    Parse a Qt `.ui` XML file, extract window geometry and user-placed widgets,
    and normalize them into a JSON layout skeleton. Widget rectangles are mapped
    onto a discrete 5-px grid and converted into 1-based row/column spans with a
    deterministic overlap resolver. Meaningful widget names in the Qt file
    (e.g., `outputFigure1`) are mapped to semantic types (`ImageView`, `TableView`, etc.).

* `GUIInputPanelJsonGenerator`
    Parse a CLI tool's `--help` text (supports C/C++ help patterns and Python
    `argparse` output) along with a curated flag list. Inject an Input Panel into
    the JSON, including:
       — labeled entry fields and checkboxes
       — tooltips derived from help text
       — `Additional options` free-text field
       — a primary **Run** button
    Also populates metadata fields (`exe_name`, `post_script`) for downstream
    execution and post-analysis steps.

* `GUIUpdatePanelJsonGenerator`
    Read a CSV-like `update_area_flags.txt` configured as:
         ``flag, Label, Description``
    and append an Update Panel containing labeled entry rows plus an
    **Update Results** button. This panel supports incremental post-analysis
    runs without re-executing the full simulation or CLI job.

Workflow summary:

    # 1) Convert the Qt `.ui` to a baseline JSON widget geometry map.
    conv = UiToJsonConverter("layout.ui")
    base = conv.convert()

    # 2) Add CLI-derived input controls.
    gen = GUIInputPanelJsonGenerator(
        app_name="MyApp",
        exe="myapp",
        input_json=base,
        flags_file="flags.txt",
        post_script="post.py",
        output_json_path="with_input.json",
    )
    gen.generate()

    # 3) Optionally attach an Update Panel for post-analysis requests.
    up = GUIUpdatePanelJsonGenerator(
        input_json=base,
        update_flags_file="update_area_flags.txt",
        output_json_path="final_layout.json",
    )
    up.generate()

This module therefore bridges visual design and execution semantics,
producing a single structured specification consumable by the code-generation
stage for PyQt6/PyMOL, Tkinter/VMD, or Panel-based web GUIs.