Skip to content

Commit

Permalink
Feature nasa#98 - Refactor UI to use table widgets
Browse files Browse the repository at this point in the history
Backend updated accordingly. Other various tweaks/fixes as needed
  • Loading branch information
lbleier-GSFC committed Jun 16, 2020
1 parent fb0ccb6 commit b0bd3fa
Show file tree
Hide file tree
Showing 16 changed files with 350 additions and 11,392 deletions.
58 changes: 27 additions & 31 deletions Subsystems/cmdGui/CommandSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import sys
from pathlib import Path

from PyQt5.QtWidgets import QApplication, QDialog
from PyQt5.QtWidgets import (QApplication, QDialog, QHeaderView, QPushButton,
QTableWidgetItem)

from Ui_CommandSystemDialog import Ui_CommandSystemDialog

Expand All @@ -43,23 +44,13 @@ def __init__(self):
self.setupUi(self)
self.move(800, 100)

for n in range(21):
btn = getattr(self, f"pushButton_{n}")
btn.clicked.connect(lambda _, x=n: self.ProcessButtonGeneric(x))

for l in range(22):
btn = getattr(self, f"quickButton_{l+1}")
btn.clicked.connect(lambda _, x=l: self.ProcessQuickButton(x))

#
# Processes 'Display Page' button
#
def ProcessButtonGeneric(self, idx):
if cmdPageIsValid[idx]:
lePID = getattr(self, f'lineEditPktId_{idx}')
leAddr = getattr(self, f'lineEdit_{idx}')
pktId = lePID.text()
address = leAddr.text()
pktId = self.tblCmdSys.item(idx, 1).text()
address = self.tblCmdSys.item(idx, 2).text()
launch_string = (
f'python3 {ROOTDIR}/{cmdClass[0]} '
f'--title=\"{cmdPageDesc[idx]}\" --pktid={pktId} '
Expand Down Expand Up @@ -87,10 +78,8 @@ def checkParams(idx):
def ProcessQuickButton(self, idx):
if cmdPageIsValid[idx] and quickIndices[idx] >= 0:
qIdx = quickIndices[idx]
lePID = getattr(self, f'lineEditPktId_{idx}')
leAddr = getattr(self, f'lineEdit_{idx}')
pktId = lePID.text()
address = leAddr.text()
pktId = self.tblCmdSys.item(idx, 1).text()
address = self.tblCmdSys.item(idx, 2).text()

# if requires parameters
if self.checkParams(qIdx):
Expand Down Expand Up @@ -128,6 +117,7 @@ def ProcessQuickButton(self, idx):
#
app = QApplication(sys.argv)
Command = CommandSystem()
tbl = Command.tblCmdSys

#
# Read in the contents of the telemetry packet definition
Expand All @@ -141,7 +131,7 @@ def ProcessQuickButton(self, idx):
reader = csv.reader(cmdfile, skipinitialspace=True)
for cmdRow in reader:
try:
if cmdRow[0][0] != '#':
if not cmdRow[0].startswith('#'):
cmdPageIsValid.append(True)
cmdPageDesc.append(cmdRow[0])
cmdPageDefFile.append(cmdRow[1])
Expand Down Expand Up @@ -190,24 +180,30 @@ def ProcessQuickButton(self, idx):
#
# fill the data fields on the page
#
for k in range(22):
subsysBrowser = getattr(Command, f'SubsysBrowser_{k}')
for k, desc in enumerate(cmdPageDesc):
if cmdPageIsValid[k]:
lineEditPktId = getattr(Command, f'lineEditPktId_{k}')
lineEditAddress = getattr(Command, f'lineEdit_{k}')
quickButton = getattr(Command, f'quickButton_{k+1}')
subsysBrowser.setText(cmdPageDesc[k])
lineEditPktId.setText(hex(cmdPageAppid[k]))
lineEditAddress.setText(cmdPageAddress[k])
tbl.insertRow(k)
for col, text in enumerate(
(desc, hex(cmdPageAppid[k]), cmdPageAddress[k])):
tblItem = QTableWidgetItem(text)
tbl.setItem(k, col, tblItem)
tblBtn = QPushButton("Display Page")
tblBtn.clicked.connect(
lambda _, x=k: Command.ProcessButtonGeneric(x))
tbl.setCellWidget(k, 3, tblBtn)
quickIdx = -1
try:
quickIdx = subsys.index(cmdPageDesc[k])
quickButton.setText(quickCmd[quickIdx])
quickIdx = subsys.index(desc)
except ValueError:
pass # Ignore quick button
pass # Ignore quick button
else:
quickBtn = QPushButton(quickCmd[quickIdx])
quickBtn.clicked.connect(
lambda _, x=k: Command.ProcessQuickButton(x))
tbl.setCellWidget(k, 4, quickBtn)
quickIndices.append(quickIdx)
else:
subsysBrowser.setText("(unused)")
tbl.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
tbl.horizontalHeader().setStretchLastSection(True)

#
# Display the page
Expand Down
Loading

0 comments on commit b0bd3fa

Please sign in to comment.