new project for personal toolbox
This commit is contained in:
26
gui/codes/common/ui2py.py
Normal file
26
gui/codes/common/ui2py.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from codes.common import clibs
|
||||
from pathlib import Path
|
||||
|
||||
UIC_CMD = "pyside6-uic"
|
||||
|
||||
|
||||
def single_uic(ui_path: str, py_path: str):
|
||||
for file in Path(ui_path).rglob("*.ui"):
|
||||
file_name = file.stem
|
||||
ui_file = file
|
||||
py_file = Path(py_path) / f"{file_name}.py"
|
||||
cmd = [UIC_CMD, "-o", py_file, ui_file]
|
||||
|
||||
print(f"Processing {ui_file} -> {py_file}")
|
||||
try:
|
||||
subprocess.run(cmd, check=True, capture_output=True, text=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"转换失败: {ui_file}\n{e.stderr}", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ui_path = clibs.base_path / "assets" / "ui"
|
||||
py_path = clibs.base_path / "codes" / "ui"
|
||||
single_uic(str(ui_path), str(py_path))
|
Reference in New Issue
Block a user