-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetaGUI.py
More file actions
229 lines (194 loc) · 8.88 KB
/
Copy pathMetaGUI.py
File metadata and controls
229 lines (194 loc) · 8.88 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import os
import time
###
import time
###
import sys
from PyQt5.QtWidgets import *
###
from MedPhys.MedPhysGUI import MedPhysWindow
from Calculus.CalculusGUI import CalculusWindow
from WavesAndOptics.WaveAndOpticsGUI import WavesAndOpticsWindow
from Analysis.AnalysisGUI import AnalysisWindow
from QuantumMechanics.QuantumMechanicsGUI import QuantumMechanicsWindow
from Mechanics.MechanicsGUI import MechanicsWindow
import MetaGUIStrings
class MetaGUI(QMainWindow):
def __init__(self,parent=None):
"""Initializes the GUI Window"""
self.tabs = QWidget()
self.language = "En"
self.BUTTON_SIZE = 40
self.DISPLAY_HEIGHT = 35
self.current_line = 1
super().__init__(parent=None)
self.setMinimumSize(300, 200)
self.generalLayout = QVBoxLayout()
centralWidget = QWidget(self)
centralWidget.setLayout(self.generalLayout)
self.setCentralWidget(centralWidget)
self.initializeGUI()
def initializeGUI(self):
self.setWindowTitle(MetaGUIStrings.GUITitle[f"{self.language}"])
self._createAnalysisButton()
self._createCalculusButton()
self._createEMButton()
self._createMechanicsButton()
self._createPhysMedButton()
self._createQMButton()
self._createStatisticsButton()
self._createWavesAndOpticsButton()
self._createExitButton()
def _createAnalysisButton(self):
"""Creates the button for the Analysis GUI"""
self.Analysis = QPushButton(MetaGUIStrings.Analysis[f"{self.language}"])
self.Analysis.setToolTip(MetaGUIStrings.OpenWindow1[f"{self.language}"] +
MetaGUIStrings.Analysis[f"{self.language}"] +
MetaGUIStrings.OpenWindow2[f"{self.language}"] +
" (Ctrl+A)")
self.Analysis.setShortcut("Ctrl+A")
self.Analysis.clicked.connect(self.openAnalysis)
self.generalLayout.addWidget(self.Analysis)
def _createCalculusButton(self):
"""Creates the button for the Calculus GUI"""
self.Calc = QPushButton(MetaGUIStrings.Calculus[f"{self.language}"])
self.Calc.setToolTip(MetaGUIStrings.OpenWindow1[f"{self.language}"] +
MetaGUIStrings.Calculus[f"{self.language}"] +
MetaGUIStrings.OpenWindow2[f"{self.language}"] +
" (Ctrl+C)")
self.Calc.setShortcut("Ctrl+C")
self.Calc.clicked.connect(self.openCalc)
self.generalLayout.addWidget(self.Calc)
def _createEMButton(self):
"""Creates the button for the Electromagnetism GUI"""
self.EM = QPushButton(MetaGUIStrings.Electromagnetism[f"{self.language}"])
self.EM.setToolTip(MetaGUIStrings.OpenWindow1[f"{self.language}"] +
MetaGUIStrings.Electromagnetism[f"{self.language}"] +
MetaGUIStrings.OpenWindow2[f"{self.language}"] +
" (Ctrl+E)")
self.EM.setShortcut("Ctrl+E")
self.EM.clicked.connect(self.openEM)
self.generalLayout.addWidget(self.EM)
def _createWavesAndOpticsButton(self):
"""Creates the button for the Waves and Optics GUI"""
self.WavesOptics = QPushButton(MetaGUIStrings.WavesAndOptics[f"{self.language}"])
self.WavesOptics.setToolTip(MetaGUIStrings.OpenWindow1[f"{self.language}"] +
MetaGUIStrings.WavesAndOptics[f"{self.language}"] +
MetaGUIStrings.OpenWindow2[f"{self.language}"] +
" (Ctrl+W)")
self.WavesOptics.setShortcut("Ctrl+W")
self.WavesOptics.clicked.connect(self.openWavesOptics)
self.generalLayout.addWidget(self.WavesOptics)
def _createPhysMedButton(self):
"""Creates the button for the Medical Physics GUI"""
self.PhysMed = QPushButton(MetaGUIStrings.MedicalPhysics[f"{self.language}"])
self.PhysMed.setToolTip(MetaGUIStrings.OpenWindow1[f"{self.language}"] +
MetaGUIStrings.MedicalPhysics[f"{self.language}"] +
MetaGUIStrings.OpenWindow2[f"{self.language}"] +
" (Ctrl+P)")
self.PhysMed.clicked.connect(self.openPhysMed)
self.PhysMed.setShortcut("Ctrl+P")
self.generalLayout.addWidget(self.PhysMed)
def _createMechanicsButton(self):
"""Creates the button for the Mechanics GUI"""
self.Mechanics = QPushButton(MetaGUIStrings.Mechanics[f"{self.language}"])
self.Mechanics.setToolTip(MetaGUIStrings.OpenWindow1[f"{self.language}"] +
MetaGUIStrings.Mechanics[f"{self.language}"] +
MetaGUIStrings.OpenWindow2[f"{self.language}"] +
" (Ctrl+N)")
self.Mechanics.clicked.connect(self.openMechanics)
self.Mechanics.setShortcut("Ctrl+N")
self.generalLayout.addWidget(self.Mechanics)
def _createStatisticsButton(self):
"""Creates the button for the Statistics GUI"""
self.Statistics = QPushButton(MetaGUIStrings.Statistics[f"{self.language}"])
self.Statistics.setToolTip(MetaGUIStrings.OpenWindow1[f"{self.language}"] +
MetaGUIStrings.Statistics[f"{self.language}"] +
MetaGUIStrings.OpenWindow2[f"{self.language}"] +
" (Ctrl+S)")
self.Statistics.clicked.connect(self.openStatistics)
self.Statistics.setShortcut("Ctrl+S")
self.generalLayout.addWidget(self.Statistics)
def _createQMButton(self):
"""Creates the button for the Quantum Mechanics GUI"""
self.QM = QPushButton(MetaGUIStrings.QuantumMechanics[f"{self.language}"])
self.QM.setToolTip(MetaGUIStrings.OpenWindow1[f"{self.language}"] +
MetaGUIStrings.QuantumMechanics[f"{self.language}"] +
MetaGUIStrings.OpenWindow2[f"{self.language}"] +
" (Ctrl+M)")
self.QM.clicked.connect(self.openQM)
self.QM.setShortcut("Ctrl+M")
self.generalLayout.addWidget(self.QM)
def _createExitButton(self):
"""Create an exit button"""
subWidget = QWidget()
layout = QHBoxLayout()
subWidget.setLayout(layout)
self.languageBox = QComboBox()
self.languageBox.addItem("En")
self.languageBox.addItem("Fr")
self.languageBox.setCurrentText(self.language)
self.languageBox.activated[str].connect(self.update_Combo_Language)
self.exit = QPushButton(MetaGUIStrings.Exit[f"{self.language}"])
self.exit.setToolTip(MetaGUIStrings.ExitTooltip[f"{self.language}"] + " (Ctrl + E)")
#self.exit.setShortcut("Ctrl+E")
self.exit.clicked.connect(self.close)
layout.addWidget(self.languageBox)
layout.addWidget(self.exit)
self.generalLayout.addWidget(subWidget)
def openAnalysis(self):
"Opens the Analysis GUI"
window = AnalysisWindow(self,language= self.language)
window.show()
def openCalc(self):
"Opens the Calculus GUI"
window = CalculusWindow(self,language= self.language)
window.show()
def openEM(self):
"Opens the Electromagnetism GUI"
pass
#window = CalculusWindow(self,language= self.language)
#window.show()
def openWavesOptics(self):
"Opens the Waves and Optics GUI"
window = WavesAndOpticsWindow(self,language= self.language)
window.show()
def openMechanics(self):
"Opens the Mechanics GUI"
window = MechanicsWindow(self,language= self.language)
window.show()
def openPhysMed(self):
"Opens the Medical Physics GUI"
window = MedPhysWindow(self,language= self.language)
window.show()
def openStatistics(self):
"Opens the Statistics GUI"
pass
#window = MedPhysWindow(self,language= self.language)
#window.show()
def openQM(self):
"Opens the Quantum Mechanics GUI"
window = QuantumMechanicsWindow(self,language= self.language)
window.show()
def update_Combo_Language(self):
"Updates the Language of the GUI"
self.language = self.languageBox.currentText()
self.refreshGUI()
def refreshGUI(self):
"""Erases all the GUI and reloads it"""
if self.generalLayout is not None:
while self.generalLayout.count():
item = self.generalLayout.takeAt(0)
widget = item.widget()
if widget is not None:
widget.deleteLater()
self.initializeGUI()
###
if __name__ == "__main__":
os.system('clear')
print(f"Starting program at {time.strftime('%H:%M:%S')}")
initial = time.time()
app = QApplication([])
window=MetaGUI()
window.show()
sys.exit(app.exec())