-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
101 lines (83 loc) · 3.19 KB
/
main.py
File metadata and controls
101 lines (83 loc) · 3.19 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
# python3
# Subin Jo
# 2022. 10. 31
import sys, os
from PyQt5 import QtWidgets, uic
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QMessageBox, QWidget, QVBoxLayout
from PyQt5.QtWebEngineWidgets import QWebEngineView
import decode, extractDJI, showFlight
ui = uic.loadUiType('UI/main.ui')[0]
class MainWindow(QMainWindow, ui):
ifn = ""
ofn = ""
strResult = ""
def __init__(self):
super().__init__()
self.setupUi(self)
self.d_inputbtn.clicked.connect(self.selectDAT)
self.d_outputbtn.clicked.connect(self.selectDir)
self.d_startbtn.clicked.connect(self.startDecode)
self.e_inputbtn.clicked.connect(self.selectDAT)
self.e_outputbtn.clicked.connect(self.selectDir)
self.e_startbtn.clicked.connect(self.startExtract)
self.csv_btn.clicked.connect(self.showFlight)
def selectDAT(self):
# path = select input .DAT file path
path = QFileDialog.getOpenFileName(self, "Select File")
if path[0]:
self.ifn = path[0]
self.d_itext.setText(self.ifn)
self.e_itext.setText(self.ifn)
else:
QMessageBox.about(self, 'Warning', 'you didn\'t select a file.')
# self.d_itext.repaint()
def selectDir(self):
# path = select output dir path
path = QFileDialog.getExistingDirectory(self, "Select Directory")
if path:
self.ofn = path
self.d_otext.setText(self.ofn)
self.e_otext.setText(self.ofn)
else:
QMessageBox.about(self, 'Warning', 'you didn\'t select a folder.')
def startDecode(self):
self.strResult += "Start Decoding\n"
self.strResult = decode.checkType(self.ifn, self.ofn, self.strResult)
# print("self.strResult: ", self.strResult)
self.strResult += "Complete Decoding\n"
self.d_result.setText(self.strResult)
def startExtract(self):
self.strResult += "Start Extracting\n"
self.strResult = extractDJI.extractDJI_main(self.ifn, self.ofn, self.strResult)
self.strResult += "Complete Extracting\n"
self.e_result.setText(self.strResult)
def showFlight(self):
if os.path.exists(self.ifn) and os.path.exists(self.ofn):
p = self.ofn + "/" + os.path.basename(self.ifn) + "_output.csv"
print(p)
if os.path.exists(p):
print("Show Flight Window")
sw = FlightWindow(p)
sw.exec()
else:
print("CSV not found")
else:
print("File Not Found")
class FlightWindow(QtWidgets.QDialog, QWidget):
def __init__(self, path):
super().__init__()
self.setWindowTitle('Flight')
self.w_width, self.w_height = 800, 500
self.setMinimumSize(self.w_width, self.w_height)
layout = QVBoxLayout()
self.setLayout(layout)
lines = showFlight.getGPS(path)
mdata = showFlight.mappingGPS(lines)
webview = QWebEngineView()
webview.setHtml(mdata.getvalue().decode())
layout.addWidget(webview)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
main = MainWindow()
main.show()
app.exec_()