From 3d126c1bdf237d98e9d203d6bd5ec513cdb01428 Mon Sep 17 00:00:00 2001 From: Greensand321 Date: Fri, 16 Jan 2026 19:20:10 -0500 Subject: [PATCH] Add Qt preview window launcher --- gui/__init__.py | 1 + gui/qt_launcher.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++ main_gui.py | 28 +++++++++++++++++++++ requirements.txt | 1 + 4 files changed, 91 insertions(+) create mode 100644 gui/__init__.py create mode 100644 gui/qt_launcher.py diff --git a/gui/__init__.py b/gui/__init__.py new file mode 100644 index 0000000..5a28004 --- /dev/null +++ b/gui/__init__.py @@ -0,0 +1 @@ +"""GUI package for optional Qt tooling.""" diff --git a/gui/qt_launcher.py b/gui/qt_launcher.py new file mode 100644 index 0000000..c155b23 --- /dev/null +++ b/gui/qt_launcher.py @@ -0,0 +1,61 @@ +"""Standalone Qt preview window launcher.""" +from __future__ import annotations + +import sys + + +QtWidgets = None +QtCore = None + +try: # Prefer PySide6 when available. + from PySide6 import QtCore, QtWidgets # type: ignore +except Exception: # pragma: no cover - optional dependency + try: + from PyQt6 import QtCore, QtWidgets # type: ignore + except Exception as exc: # pragma: no cover - optional dependency + raise SystemExit( + "PySide6 or PyQt6 is required to launch the Qt preview window. " + "Install one of them and try again." + ) from exc + + +class QtPreviewWindow(QtWidgets.QMainWindow): + """Simple placeholder Qt window for incremental migration.""" + + def __init__(self) -> None: + super().__init__() + self.setWindowTitle("AlphaDEX Qt Preview") + self.resize(900, 600) + + container = QtWidgets.QWidget() + layout = QtWidgets.QVBoxLayout(container) + + heading = QtWidgets.QLabel("Qt Preview Window") + heading.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) + heading.setStyleSheet("font-size: 20px; font-weight: 600;") + + body = QtWidgets.QLabel( + "This window is launched from the Tkinter app to begin a staged Qt migration.\n" + "Add new Qt panels here as they are ported from the Tk interface." + ) + body.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) + body.setWordWrap(True) + + layout.addStretch(1) + layout.addWidget(heading) + layout.addSpacing(12) + layout.addWidget(body) + layout.addStretch(2) + + self.setCentralWidget(container) + + +def main() -> int: + app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv) + window = QtPreviewWindow() + window.show() + return app.exec() + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/main_gui.py b/main_gui.py index b8d2826..61829f7 100644 --- a/main_gui.py +++ b/main_gui.py @@ -29,6 +29,7 @@ # from ttkthemes import ThemedStyle as Style # import ttkbootstrap as tb; Style = tb.Style import json +import importlib.util import queue import subprocess from tkinter import filedialog, messagebox, Text, Scrollbar @@ -6137,6 +6138,10 @@ def build_ui(self): label="Duplicate Pair Review…", command=self._open_duplicate_pair_review_tool, ) + tools_menu.add_command( + label="Qt Preview Window…", + command=self._open_qt_preview_window, + ) tools_menu.add_command(label="M4A Tester…", command=self._open_m4a_tester_tool) tools_menu.add_command(label="Opus Tester…", command=self._open_opus_tester_tool) tools_menu.add_separator() @@ -8638,6 +8643,29 @@ def _open_file_cleanup_tool(self) -> None: def _open_duplicate_bucketing_poc_tool(self) -> None: DuplicateBucketingPocDialog(self) + def _open_qt_preview_window(self) -> None: + qt_available = any( + importlib.util.find_spec(module) + for module in ("PySide6", "PyQt6") + ) + if not qt_available: + messagebox.showerror( + "Qt Preview", + "PySide6 or PyQt6 is not installed. Install one of them to launch the Qt preview window.", + ) + return + + try: + subprocess.Popen( + [sys.executable, "-m", "gui.qt_launcher"], + cwd=str(Path(__file__).resolve().parent), + ) + except Exception as exc: + messagebox.showerror( + "Qt Preview", + f"Unable to launch the Qt preview window: {exc}", + ) + def _open_m4a_tester_tool(self) -> None: M4ATesterDialog(self) diff --git a/requirements.txt b/requirements.txt index 71ef1c1..3ccbde7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,6 +29,7 @@ tqdm ttkthemes ttkbootstrap sv-ttk +PySide6 # Optional alternative audio engine; see README.md for install steps # essentia==2.1b6