Skip to content

Commit 2e7417e

Browse files
committed
Add gui init
Add gui init
1 parent 4ffa8ee commit 2e7417e

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

automation_file/gui/__init__.py

Whitespace-only changes.

automation_file/gui/main_widget.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
5+
if TYPE_CHECKING:
6+
from je_auto_control.gui.main_window import AutoControlGUI
7+
8+
from PySide6.QtWidgets import QWidget, QGridLayout
9+
10+
11+
class AutoControlWidget(QWidget):
12+
13+
def __init__(self, main_ui: AutoControlGUI):
14+
super().__init__()
15+
# Variable
16+
self.main_ui = main_ui
17+
# UI component
18+
# Grid layout
19+
self.grid_layout = QGridLayout()
20+
self.setLayout(self.grid_layout)

automation_file/gui/main_window.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

Comments
 (0)