forked from UBC-Rocket/UBCRocketGroundStation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
59 lines (45 loc) · 1.96 KB
/
Copy pathstart.py
File metadata and controls
59 lines (45 loc) · 1.96 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
import sys
import multiprocessing
import argparse
import matplotlib
matplotlib.use('QT5Agg') # Ensures that the Qt5 backend is used, otherwise there might be some issues on some OSs (Mac)
from com_window.main import ComWindow
from PyQt5 import QtWidgets, QtCore
from profiles.rockets.tantalus import TantalusProfile
from util.self_test import SelfTest
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
MIN_APP_FONT_POINT_SIZE = 8
if __name__ == "__main__":
# Pyinstaller fix https://stackoverflow.com/questions/32672596/pyinstaller-loads-script-multiple-times
multiprocessing.freeze_support()
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--self-test", action='store_true')
args, unparsed_args = parser.parse_known_args()
# QApplication expects the first argument to be the program name.
qt_args = sys.argv[:1] + unparsed_args
app = QtWidgets.QApplication(qt_args)
font = app.font()
font.setPointSize(max(MIN_APP_FONT_POINT_SIZE, font.pointSize()))
app.setFont(font)
if not args.self_test:
# Open com_window dialog to get startup details
com_window = ComWindow()
com_window.show()
return_code = app.exec_()
if return_code != 0 or com_window.chosen_rocket is None or com_window.chosen_connection is None:
sys.exit(return_code)
rocket = com_window.chosen_rocket
connection = com_window.chosen_connection
main_window = rocket.construct_app(connection)
else:
rocket = TantalusProfile()
connection = rocket.construct_debug_connection()
main_window = rocket.construct_app(connection)
test = SelfTest(main_window)
test.start()
main_window.show()
return_code = app.exec_()
sys.exit(return_code)