9779baa468
Move all application source under src/pygui/ and rewire imports, build config, and QML module path to match. - Relocate backend/, serialcomm/, and the ISC QML module into src/pygui/; convert main.py into pygui/__main__.py with a main() entry point (run via `python -m pygui` or the new `isc` script) - Rewrite absolute imports: backend.* -> pygui.backend.*, serialcomm.* -> pygui.serialcomm.* (source + tests) - Move app icons (isc.ico/icns) into packaging/ - Update README and ISC.qmlproject to the new paths
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
from PySide6.QtQml import QQmlApplicationEngine
|
|
from PySide6.QtQuickControls2 import QQuickStyle
|
|
from PySide6.QtWidgets import QApplication
|
|
|
|
from pygui.backend.device_controller import DeviceController
|
|
from pygui.backend.local_settings import LocalSettings
|
|
from pygui.backend.local_settings_model import LocalSettingsModel
|
|
from pygui.backend.file_browser import FileBrowser
|
|
|
|
|
|
# ===== Application Entry Point =====
|
|
def main() -> int:
|
|
# ===== UI Style Setup =====
|
|
# Use a non-native controls style so our custom QML button backgrounds are supported.
|
|
QQuickStyle.setStyle("Basic")
|
|
|
|
# ===== Qt Bootstrap =====
|
|
# Minimal Qt bootstrap: load the ISC QML module and exit if it fails.
|
|
app = QApplication(sys.argv)
|
|
engine = QQmlApplicationEngine()
|
|
|
|
# ===== Shared Models =====
|
|
settings_model = LocalSettingsModel()
|
|
select_file_dialog_model = FileBrowser()
|
|
settings_model.loadSettings()
|
|
engine.rootContext().setContextProperty("settingsModel", settings_model)
|
|
engine.rootContext().setContextProperty("file_browser", select_file_dialog_model)
|
|
|
|
# ===== Device Controller (serial comm) =====
|
|
data_dir = str(settings_model._data_dir)
|
|
raw_settings = LocalSettings.read_settings(data_dir)
|
|
device_controller = DeviceController(raw_settings, data_dir)
|
|
engine.rootContext().setContextProperty("deviceController", device_controller)
|
|
|
|
# ===== QML Startup =====
|
|
# The "ISC" QML module lives alongside this file (src/pygui/ISC), so the
|
|
# package directory is the import path the engine searches for qmldir.
|
|
engine.addImportPath(Path(__file__).parent)
|
|
engine.loadFromModule("ISC", "Main")
|
|
|
|
# ===== Exit Handling =====
|
|
if not engine.rootObjects():
|
|
return -1
|
|
|
|
return app.exec()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|