Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect UI #4

Merged
merged 10 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 59 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
###################################################################################

from PyQt5 import uic
from PyQt5.QtWidgets import QApplication, QLabel, QMainWindow, QWidget
from PyQt5.QtWidgets import QFileDialog, QApplication, QLabel, QMainWindow, QWidget
from PyQt5.QtCore import Qt


from platform_comms_app import Ui_Form

class MainWindow(QWidget, Ui_Form):
Expand All @@ -29,21 +30,74 @@ def __init__(self, *args, obj=None, **kwargs):
self.setupUi(self)

# Should do that for all UI items, need to do this in QT designer.
self.pushButtonSendPcTime.clicked.connect(self.onClick)
self.pushButtonSendPcTime.clicked.connect(self.onSendPcTime)
self.pushButtonSendThisTime.clicked.connect(self.onClickThisTime)
self.pushButtonSendTCReq.clicked.connect(self.onClickSendTCReq)
self.pushButtonSendTlmReq.clicked.connect(self.onClickSendTLMReq)

self.pushButtonOpenFileUploadFrom.clicked.connect(self.onClickUploadOpen)
self.pushButtonOpenFileDownloadTo.clicked.connect(self.onClickDownloadOpen)

# TODO: I think there is a better way to handle events
# There is event handlers and signals, not sure what to use.
# https://www.learnpyqt.com/tutorials/signals-slots-events/
def onClick(self, event):
def onSendPcTime(self, event):
# TODO: get pc time and send it.
print('Clicked: Send PC Time')

def onClickThisTime(self, event):
# Just a test so see how we can get data from other UI items.
dateFromUi = self.dateEditSendThisTime.dateTime()
dateString = dateFromUi.toString(self.dateEditSendThisTime.displayFormat())

timeFromUI = self.dateTimeEditSendThisTime.dateTime()
timeString = timeFromUI.toString(self.dateTimeEditSendThisTime.displayFormat())

print('Clicked: Send This Time')
print(timeString)
print('Date: {}'.format(dateString))
print('Time: {}'.format(timeString))

def onClickSendTCReq(self, event):
tc = self.inputTelecommandN.text()
data = self.inputTelecommandData.text()
# Text value of the comboBox. see: https://doc.qt.io/qt-5/qcombobox.html#currentData-prop
comboBox = self.comboBoxTelemetry.currentText()

# It returns 2 for true, and 0 for false. Is this normal in py? 0/1 is what i would expect.
isContinuous = self.checkBoxTelemetryContinuous.checkState() == 2

print('TC: {}'.format(tc))
print('Data: {}'.format(data))
print('ComboBox: {}'.format(comboBox))
print('Is continuous: {}'.format(isContinuous))

def onClickSendTLMReq(self, event):
# labelTimeOuts
tlmChannel = self.lineEditChannel.text()
isContinuous = self.checkBoxLastReqContinuous.checkState() == 2

# Set the TIMEOUTS value here;
self.labelTLMTimeouts.setText('hello')

print('Channel: {}'.format(tlmChannel))
print('Is continuous: {}'.format(isContinuous))

def onClickUploadOpen(self, event):
fileDialog = QFileDialog(self)
fileDialog.show()

filePath = fileDialog.getOpenFileName()[0];
fileDialog.hide()

self.lineEditUploadFrom.setText(filePath)

def onClickDownloadOpen(self, event):
fileDialog = QFileDialog(self)
fileDialog.show()

filePath = fileDialog.getOpenFileName()[0];
fileDialog.hide()

self.lineEditDownloadTo.setText(filePath)

app = QApplication([])
window = MainWindow()
Expand Down
Loading