gui_app.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. """
  2. Entry point for the MRI Sequence Interpreter GUI.
  3. Run from the repo root:
  4. python -m seq_interp.gui_app
  5. or:
  6. python seq_interp/gui_app.py
  7. Optionally pass a .seq file as the first CLI argument to pre-load it:
  8. python seq_interp/gui_app.py data/input/test1_full.seq
  9. """
  10. from __future__ import annotations
  11. import os
  12. import sys
  13. # Ensure the repo root is importable regardless of how the script is invoked.
  14. _here = os.path.dirname(os.path.abspath(__file__))
  15. _repo_root = os.path.dirname(os.path.dirname(_here))
  16. _lf_scanner_root = os.path.join(_repo_root, "libs", "lf-scanner")
  17. for _path in (_repo_root, _lf_scanner_root):
  18. if _path not in sys.path:
  19. sys.path.insert(0, _path)
  20. import argparse
  21. from PySide6.QtWidgets import QApplication
  22. from seq_interp.src.gui.main_window import MainWindow
  23. def main() -> None:
  24. parser = argparse.ArgumentParser(
  25. description="MRI Sequence Interpreter - interactive GUI"
  26. )
  27. parser.add_argument(
  28. "seq_file", nargs="?", default=None,
  29. help="Optional .seq file to load on startup",
  30. )
  31. parser.add_argument(
  32. "--hw-config", default=None,
  33. help="Optional hardware config JSON to load on startup",
  34. )
  35. parser.add_argument(
  36. "--output-dir", default=None,
  37. help="Optional output directory",
  38. )
  39. args = parser.parse_args()
  40. app = QApplication(sys.argv)
  41. app.setApplicationName("MRI Sequence Interpreter")
  42. app.setOrganizationName("LF-MRI")
  43. # Qt6 / PySide6: high-DPI is enabled automatically - AA_UseHighDpiPixmaps
  44. # is deprecated and emits a DeprecationWarning; omit it.
  45. win = MainWindow()
  46. # Pre-load files from CLI arguments if given
  47. if args.hw_config and os.path.isfile(args.hw_config):
  48. win._hw_config_path = os.path.abspath(args.hw_config)
  49. win._log(f"HW config pre-loaded: {win._hw_config_path}")
  50. if args.output_dir:
  51. win._output_dir = os.path.abspath(args.output_dir)
  52. win._log(f"Output dir: {win._output_dir}")
  53. if args.seq_file and os.path.isfile(args.seq_file):
  54. win._seq_path = os.path.abspath(args.seq_file)
  55. name = os.path.basename(win._seq_path)
  56. win._set_seq_state("selected", name)
  57. win._btn_run.setEnabled(True)
  58. win._log(f"Sequence pre-loaded: {win._seq_path}")
  59. # Start in a maximized windowed state so the app fills the usable screen
  60. # area while preserving the native title bar and taskbar.
  61. win.showMaximized()
  62. sys.exit(app.exec())
  63. if __name__ == "__main__":
  64. main()