This repository has been archived by the owner on May 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
51 lines (38 loc) · 1.45 KB
/
main.py
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
import sys, time
from PyQt5 import QtWidgets, uic, QtGui, QtCore
from mainwindow import Ui_MainWindow
from connectionHandler import *
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super(MainWindow,self).__init__()
self.setupUi(self)
self.setStyleSheet(open('style/mainWindow.css').read())
self.setupThread()
self.connectButtons()
def connectButtons(self):
self.connectionBar.b_connect.pressed.connect(self.manageConnection)
def setupThread(self):
self.telemetryThread=QtCore.QThread()
self.handler = connectionHandler()
self.handler.moveToThread(self.telemetryThread)
self.telemetryThread.started.connect(self.handler.receiveData)
self.handler.dataReceived.connect(self.updateWidgets)
def manageConnection(self):
if self.telemetryThread.isRunning():
self.handler.dataReceived.disconnect()
self.handler.stop()
self.telemetryThread.exit()
else:
self.telemetryThread.start()
self.handler.start()
self.handler.dataReceived.connect(self.updateWidgets)
self.connectionBar.sendData.connect(self.handler.sendData)
def updateWidgets(self, data):
hum = data[0]
self.connectionBar.update(hum)
def main():
app=QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
main()