Basic structure for the QT application with empty window
This commit is contained in:
64
scripts/generate_qt_files.py
Normal file
64
scripts/generate_qt_files.py
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
GUI_PACKAGE = ROOT / "src" / "bedit_gui"
|
||||
|
||||
FORMS_DIR = GUI_PACKAGE / "ui" / "forms"
|
||||
GENERATED_UI_DIR = GUI_PACKAGE / "ui" / "generated"
|
||||
|
||||
QRC_FILE = GUI_PACKAGE / "resources" / "resources.qrc"
|
||||
GENERATED_RESOURCES = (
|
||||
GUI_PACKAGE
|
||||
/ "resources"
|
||||
/ "resources_rc.py"
|
||||
)
|
||||
|
||||
|
||||
def execute(*command: str) -> None:
|
||||
print("+", " ".join(command))
|
||||
subprocess.run(command, check=True)
|
||||
|
||||
|
||||
def generate_ui() -> None:
|
||||
GENERATED_UI_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for source in sorted(FORMS_DIR.glob("*.ui")):
|
||||
destination = GENERATED_UI_DIR / f"ui_{source.stem}.py"
|
||||
|
||||
execute(
|
||||
"pyside6-uic",
|
||||
"--absolute-imports",
|
||||
"--python-paths",
|
||||
str(ROOT / "src"),
|
||||
str(source),
|
||||
"-o",
|
||||
str(destination),
|
||||
)
|
||||
|
||||
|
||||
def generate_resources() -> None:
|
||||
GENERATED_RESOURCES.parent.mkdir(
|
||||
parents=True,
|
||||
exist_ok=True,
|
||||
)
|
||||
|
||||
execute(
|
||||
"pyside6-rcc",
|
||||
str(QRC_FILE),
|
||||
"-o",
|
||||
str(GENERATED_RESOURCES),
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
generate_ui()
|
||||
generate_resources()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user