Add repo-local GUI runner scripts

This commit is contained in:
Meta Vens 2026-04-24 15:10:48 +01:00
commit 7cc958a008
4 changed files with 99 additions and 0 deletions

25
scripts/run_gui.ps1 Normal file
View file

@ -0,0 +1,25 @@
param(
[string]$BindHost = "127.0.0.1",
[int]$Port = 8000,
[switch]$Reload
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent $PSScriptRoot
$python = Join-Path $repoRoot ".venv\Scripts\python.exe"
if (-not (Test-Path $python)) {
$python = "python"
}
$args = @(
(Join-Path $repoRoot "scripts\run_gui.py"),
"--host", $BindHost,
"--port", $Port
)
if ($Reload) {
$args += "--reload"
}
& $python @args

36
scripts/run_gui.py Normal file
View file

@ -0,0 +1,36 @@
from __future__ import annotations
import argparse
import sys
from pathlib import Path
def _repo_root() -> Path:
return Path(__file__).resolve().parents[1]
def _ensure_src_on_path() -> None:
src = _repo_root() / "src"
src_text = str(src)
if src_text not in sys.path:
sys.path.insert(0, src_text)
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="Launch the Repixelizer GUI from the repo checkout.")
parser.add_argument("--host", default="127.0.0.1", help="Host interface to bind")
parser.add_argument("--port", type=int, default=8000, help="Port to bind")
parser.add_argument("--reload", action="store_true", help="Enable autoreload while developing the GUI server")
return parser
def main(argv: list[str] | None = None) -> int:
_ensure_src_on_path()
from repixelizer.gui import main as gui_main
args = build_parser().parse_args(argv)
return gui_main(host=args.host, port=args.port, reload=args.reload)
if __name__ == "__main__":
raise SystemExit(main())