-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCarMakerUI.py
More file actions
93 lines (73 loc) · 3.08 KB
/
Copy pathCarMakerUI.py
File metadata and controls
93 lines (73 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import sys
import subprocess
import cmapi
import pathlib
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QFileDialog, QLabel
from PyQt5.QtGui import QIcon
class SimpleGUI(QWidget):
def __init__(self):
super().__init__()
self.project_path = None
self.init_ui()
def init_ui(self):
# Create Button
self.start_button = QPushButton('Start', self)
self.stop_button = QPushButton('Stop', self)
self.open_button = QPushButton('Open', self)
self.select_path_button = QPushButton('프로젝트 경로 선택', self)
self.load_project_button = QPushButton('프로젝트 불러오기', self)
# Create Event Handler connected for button
self.start_button.clicked.connect(self.start_clicked)
self.stop_button.clicked.connect(self.stop_clicked)
self.open_button.clicked.connect(self.open_clicked)
self.select_path_button.clicked.connect(self.select_path_clicked)
self.load_project_button.clicked.connect(self.load_project_clicked)
# Layout and add button
layout = QVBoxLayout()
layout.addWidget(self.select_path_button)
layout.addWidget(self.load_project_button)
layout.addWidget(self.start_button)
layout.addWidget(self.stop_button)
layout.addWidget(self.open_button)
self.path_label = QLabel(self)
layout.addWidget(self.path_label)
self.setLayout(layout)
# 창 크기 및 제목 설정
self.setGeometry(300, 300, 400, 200)
self.setWindowTitle('CarMaker 12.0.1')
def select_path_clicked(self):
# 폴더 대화 상자를 통해 경로 선택
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
selected_folder = QFileDialog.getExistingDirectory(self, "프로젝트 폴더 선택", options=options)
if selected_folder:
# 선택된 폴더 경로를 변수에 저장
self.project_path = pathlib.Path(selected_folder)
# 선택된 경로를 레이블에 표시
self.path_label.setText(f'선택된 프로젝트 경로: {str(self.project_path)}')
def load_project_clicked(self):
if self.project_path:
try:
# 프로젝트 로드
cmapi.Project.load(self.project_path)
except Exception as e:
print(f'프로젝트를 불러오는 중 오류 발생: {e}')
else:
print('프로젝트 경로가 선택되지 않았습니다.')
def start_clicked(self):
print('Start Simulation')
def stop_clicked(self):
print('Stop Simulation')
def open_clicked(self):
file_path = r'C:\IPG\carmaker\win64-12.0.1\bin\CM.exe'
try:
subprocess.run([file_path], check=True)
except subprocess.CalledProcessError as e:
print(f'Error: {e}')
print('Run CarMaker')
if __name__ == '__main__':
app = QApplication(sys.argv)
gui = SimpleGUI()
gui.show()
cmapi.Task.run_main_task(main())
sys.exit(app.exec_())