![]() |
Structural Bioinformatics Library
Template C++ / Python API for developping structural bioinformatics applications.
|
Static Public Member Functions | |
| str | generate_codes (str spec_file, str framework, str exe_name, str post_script="") |
Stateless dispatch class that converts a JSON GUI specification into
runnable source code for a selected GUI framework.
Pipeline stage:
Spec JSON → Parsed `GUI` object → Framework-specific Python code
Backends:
* PyQt6 (`gui_codegen_PyQt6.GeneratorPyQt6`)
* Tkinter (`gui_codegen_Tkinter.GeneratorTkinter`)
* Panel (`gui_codegen_panel.GeneratorPanel`, NGL.js or Three.js mode)
Characteristics:
- No internal state retained
- Lazy imports to keep dependency footprint minimal
- Caller decides where to store the produced code file(s)
Typical usage:
from gui_codegen import CodeGenerator
python_source = CodeGenerator.generate_codes(
spec_file="Spec.json",
framework="pyqt",
exe_name="analyze.exe",
post_script="post.py",
)
Converts a JSON GUI specification into runnable source code for a selected GUI framework. Serves as the main entry point for the GUI code generation process, handling the orchestration of various steps involved in transforming a JSON specification into a fully functional GUI application.
|
static |
Generate Python GUI source code from a validated JSON specification.
Args:
spec_file: Path to the GUI spec file (UTF-8 encoded JSON).
framework: Target UI backend; case-insensitive aliases allowed:
┌──────────────────────┬────────────────────┐
│ Alias │ Framework │
├──────────────────────┼────────────────────┤
│ "qt", "pyqt", "pymol"│ PyQt6 │
│ "tk", "tkinter","vmd"│ Tkinter │
│ "panel-ngljs" │ Panel + NGL.js │
│ "panel-threejs" │ Panel + Three.js │
└──────────────────────┴────────────────────┘
exe_name: Name of the CLI executable bound to the "Run" action.
post_script: Optional Python script executed after CLI completion.
Returns:
String containing a fully-formed Python GUI module.
Caller is responsible for writing it to disk if desired.
Raises:
ValueError: If the framework identifier is unknown.
Workflow:
1. Load JSON → dict
2. Validate & parse → `GUI` dataclass tree
3. Select backend generator and emit Python code