forked from melli0505/PyQt_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
173 lines (143 loc) · 6.36 KB
/
Copy pathmain.py
File metadata and controls
173 lines (143 loc) · 6.36 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import sys
import time as tm
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import *
from PyQt5 import QtWidgets
from mainSetting.Setting import *
from measurement.measurement import *
# main ui control
class SoundCam(QWidget):
def __init__(self):
super().__init__()
self.stacked_widget = QStackedWidget(self)
self.main_window = MainWindow()
self.setting_page = SettingPage()
self.setting_btns = SettingBtn()
self.measurement_page = MeasurementWidget()
self.initUI()
def initUI(self):
self.setWindowTitle('SoundCam')
self.resize(720, 480)
widget_layout = QBoxLayout(QtWidgets.QBoxLayout.LeftToRight)
self.stacked_widget.addWidget(self.main_window)
self.stacked_widget.addWidget(self.setting_page)
self.stacked_widget.addWidget(self.setting_btns)
self.stacked_widget.addWidget(self.measurement_page)
widget_layout.addWidget(self.stacked_widget)
self.setLayout(widget_layout)
self.main_window.setting_btn.clicked.connect(self.go_setting)
self.main_window.start_btn.clicked.connect(self.start)
self.measurement_page.exit_btn.clicked.connect(self.back_to_main)
self.main_window.file_btn.clicked.connect(self.FileOpen)
def go_setting(self):
self.stacked_widget.setCurrentWidget(self.setting_page)
def back_to_main(self):
self.stacked_widget.setCurrentWidget(self.main_window)
def start(self):
self.stacked_widget.setCurrentWidget(self.measurement_page)
def FileOpen(self):
fileName = QFileDialog.getOpenFileName(self, self.tr("Open Data Files"), './', self.tr(
"Data Files (*.csv *.xls *.xlsx);; Images (*.png *.xpm *.jpg *.gif);; All Files(*.*)"))
print("load file : ", self.fileName[0])
return fileName
# main page
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('SoundCam')
self.resize(720, 480)
# 측정 시작 버튼
self.start_btn = QPushButton(flat=True)
self.start_btn.setIcon(QIcon('icons/broadcast.png'))
self.start_btn.setIconSize(QSize(200, 200))
self.start_btn.setMaximumHeight(1000)
self.start_btn.setStyleSheet(
"QPushButton { color: black; background-color: #519AA4; border-radius: 5px;}"
"QPushButton:pressed { background-color: #305F65; }"
)
# 설정 버튼
self.setting_btn = QPushButton(flat=True)
self.setting_btn.setIcon(QIcon('icons/setting.png'))
self.setting_btn.setIconSize(QSize(100, 100))
self.setting_btn.setMaximumHeight(300)
self.setting_btn.setMaximumWidth(300)
self.setting_btn.setStyleSheet(
'QPushButton { color: black; background-color: #55B0BC; border-radius: 5px;}'
'QPushButton:pressed { background-color: #305F65 }'
)
# 전원 on/off 버튼
self.power_btn = QPushButton(flat=True)
self.power_btn.setIcon(QIcon('icons/power.png'))
self.power_btn.setIconSize(QSize(100, 100))
self.power_btn.setMaximumHeight(300)
self.power_btn.setMaximumWidth(300)
self.power_btn.setStyleSheet(
"QPushButton { color: black; background-color: #55B0BC; border-radius: 5px;}"
"QPushButton:pressed { background-color: #305F65 }"
)
self.power_btn.clicked.connect(QCoreApplication.instance().quit)
# 정보창 버튼
self.info_btn = QPushButton(flat=True)
self.info_btn.setIcon(QIcon('icons/info.png'))
self.info_btn.setIconSize(QSize(100, 100))
self.info_btn.setMaximumHeight(300)
self.info_btn.setMaximumWidth(300)
self.info_btn.setStyleSheet(
"QPushButton { color: black; background-color: #55B0BC; border-radius: 5px;}"
"QPushButton:pressed { background-color: #305F65 }"
)
# 프로필 버튼
self.profile_btn = QPushButton(flat=True)
self.profile_btn.setIcon(QIcon('icons/profiles.png'))
self.profile_btn.setIconSize(QSize(100, 100))
self.profile_btn.setMaximumHeight(300)
self.profile_btn.setMaximumWidth(300)
self.profile_btn.setStyleSheet(
"QPushButton { color: black; background-color: #55B0BC; border-radius: 5px;}"
"QPushButton:pressed { background-color: #305F65 }"
)
# 파일 불러오기 버튼
self.file_btn = QPushButton(flat=True)
self.file_btn.setIcon(QIcon('icons/file.png'))
self.file_btn.setIconSize(QSize(100, 100))
self.file_btn.setMaximumHeight(300)
self.file_btn.setMaximumWidth(700)
self.file_btn.setStyleSheet(
"QPushButton { color: black; background-color: #55B0BC; border-radius: 5px;}"
"QPushButton:pressed { background-color: #305F65 }"
)
# 그리드 추가
main_box = QGridLayout(self)
main_box.addWidget(self.start_btn, 0, 0, 3, 2)
main_box.addWidget(self.setting_btn, 0, 2, 1, 1)
main_box.addWidget(self.power_btn, 0, 3, 1, 1)
main_box.addWidget(self.info_btn, 1, 2, 1, 1)
main_box.addWidget(self.profile_btn, 1, 3, 1, 1)
main_box.addWidget(self.file_btn, 2, 2, 1, 2)
# run
if __name__ == '__main__':
app = QApplication(sys.argv)
# Create and display the splash screen
splash_pix = QPixmap('img/splashLogo.png')
splash_pix = splash_pix.scaled(720, 480)
splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
splash.setEnabled(False)
# adding progress bar
progressBar = QProgressBar(splash)
progressBar.setMaximum(10)
progressBar.setGeometry(10, splash_pix.height() - 50, splash_pix.width()-5, 20)
splash.show()
splash.showMessage("<h1><font color='white'>Welcome SoundCam!</font></h1>", Qt.AlignTop , Qt.black)
for i in range(1, 11):
progressBar.setValue(i)
pt = tm.time()
while tm.time() < pt + 0.1:
app.processEvents()
# Simulate something that takes time
tm.sleep(1)
ex = SoundCam()
ex.show()
splash.finish(ex)
sys.exit(app.exec_())