|
| 1 | +import os |
| 2 | +import sys |
| 3 | +from pathlib import Path |
| 4 | + |
| 5 | +from PySide6.QtCore import QCoreApplication, QTimer |
| 6 | +from PySide6.QtGui import QIcon |
| 7 | +from PySide6.QtWidgets import QMainWindow, QApplication |
| 8 | +from qt_material import apply_stylesheet |
| 9 | + |
| 10 | +from je_auto_control.gui.main_widget import AutoControlWidget |
| 11 | + |
| 12 | + |
| 13 | +class AutoControlGUI(QMainWindow): |
| 14 | + |
| 15 | + def __init__(self, debug_mode: bool = False): |
| 16 | + super().__init__() |
| 17 | + self.debug_mode = debug_mode |
| 18 | + self.central_widget = AutoControlWidget(self) |
| 19 | + self.setCentralWidget(self.central_widget) |
| 20 | + self.setWindowTitle("AutoControlGUI") |
| 21 | + # Set Icon |
| 22 | + self.icon_path = Path(os.getcwd() + "/je_driver_icon.ico") |
| 23 | + self.icon = QIcon(str(self.icon_path)) |
| 24 | + if self.icon.isNull() is False: |
| 25 | + self.setWindowIcon(self.icon) |
| 26 | + if self.debug_mode: |
| 27 | + close_timer = QTimer(self) |
| 28 | + close_timer.setInterval(10000) |
| 29 | + close_timer.timeout.connect(self.debug_close) |
| 30 | + close_timer.start() |
| 31 | + |
| 32 | + @classmethod |
| 33 | + def debug_close(cls): |
| 34 | + sys.exit(0) |
| 35 | + |
| 36 | + |
| 37 | +def start_autocontrol_gui(debug_mode: bool = False) -> None: |
| 38 | + autocontrol_gui = QCoreApplication.instance() |
| 39 | + if autocontrol_gui is None: |
| 40 | + autocontrol_gui = QApplication(sys.argv) |
| 41 | + window = AutoControlGUI(debug_mode) |
| 42 | + apply_stylesheet(autocontrol_gui, theme='dark_amber.xml') |
| 43 | + window.showMaximized() |
| 44 | + sys.exit(autocontrol_gui.exec()) |
0 commit comments