Updated view for better readibility.

This commit is contained in:
jupfi 2023-07-31 15:43:54 +02:00
parent 3180f13c82
commit c7a7440cf0
4 changed files with 114 additions and 75 deletions

View file

@ -26,3 +26,5 @@ class AutoTMController(ModuleController):
except serial.SerialException as e:
logger.error("Failed to connect to device %s", device)
logger.error(e)

View file

@ -23,7 +23,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="titleconnectionLabel">
<property name="font">
<font>
<weight>75</weight>
@ -40,6 +40,13 @@
<item row="0" column="1">
<widget class="QComboBox" name="portBox"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="refreshButton">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
@ -48,37 +55,30 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="refreshButton">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Connected to:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="connectionLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Connected to:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_3">
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titletypeLabel">
<property name="font">
<font>
<weight>75</weight>
@ -91,10 +91,21 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox"/>
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Mechanical</string>
</property>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Electrical</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="titlefrequencyLabel">
<property name="font">
<font>
<weight>75</weight>
@ -142,15 +153,15 @@
</property>
</widget>
</item>
<item row="2" column="1">
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Start Sweep</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
@ -159,7 +170,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<widget class="QLabel" name="titleinfoLabel">
<property name="font">
<font>
<weight>75</weight>
@ -182,7 +193,7 @@
<x>0</x>
<y>0</y>
<width>273</width>
<height>231</height>
<height>229</height>
</rect>
</property>
</widget>
@ -193,7 +204,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="MplWidget" name="S11" native="true">
<widget class="MplWidget" name="S11Plot" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>

View file

@ -37,6 +37,28 @@ class AutoTMView(ModuleView):
self._ui_form.scrollAreaWidgetContents.setLayout(QVBoxLayout())
self._ui_form.scrollAreaWidgetContents.layout().setAlignment(Qt.AlignmentFlag.AlignTop)
self.init_plot()
self.init_labels()
def init_labels(self) -> None:
"""Makes some of the labels bold for better readability.
"""
self._ui_form.titleconnectionLabel.setStyleSheet("font-weight: bold;")
self._ui_form.titlefrequencyLabel.setStyleSheet("font-weight: bold;")
self._ui_form.titletypeLabel.setStyleSheet("font-weight: bold;")
self._ui_form.titleinfoLabel.setStyleSheet("font-weight: bold;")
def init_plot(self) -> None:
"""Initialize the S11 plot. """
ax = self._ui_form.S11Plot.canvas.ax
ax.set_xlabel("Frequency (MHz)")
ax.set_ylabel("S11 (dB)")
ax.set_title("S11")
ax.grid(True)
ax.set_xlim(0, 100)
ax.set_ylim(-100, 0)
self._ui_form.S11Plot.canvas.draw()
@pyqtSlot(list)
def on_available_devices_changed(self, available_devices : list) -> None:
"""Update the available devices list in the view. """

View file

@ -22,52 +22,54 @@ class Ui_Form(object):
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.label_2 = QtWidgets.QLabel(parent=Form)
self.titleconnectionLabel = QtWidgets.QLabel(parent=Form)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.verticalLayout_2.addWidget(self.label_2)
self.titleconnectionLabel.setFont(font)
self.titleconnectionLabel.setObjectName("titleconnectionLabel")
self.verticalLayout_2.addWidget(self.titleconnectionLabel)
self.gridLayout_2 = QtWidgets.QGridLayout()
self.gridLayout_2.setObjectName("gridLayout_2")
self.portBox = QtWidgets.QComboBox(parent=Form)
self.portBox.setObjectName("portBox")
self.gridLayout_2.addWidget(self.portBox, 0, 1, 1, 1)
self.refreshButton = QtWidgets.QPushButton(parent=Form)
self.refreshButton.setObjectName("refreshButton")
self.gridLayout_2.addWidget(self.refreshButton, 0, 2, 1, 1)
self.label = QtWidgets.QLabel(parent=Form)
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
self.connectButton = QtWidgets.QPushButton(parent=Form)
self.connectButton.setObjectName("connectButton")
self.gridLayout_2.addWidget(self.connectButton, 1, 1, 1, 1)
self.refreshButton = QtWidgets.QPushButton(parent=Form)
self.refreshButton.setObjectName("refreshButton")
self.gridLayout_2.addWidget(self.refreshButton, 1, 0, 1, 1)
self.label_10 = QtWidgets.QLabel(parent=Form)
self.label_10.setObjectName("label_10")
self.gridLayout_2.addWidget(self.label_10, 2, 0, 1, 1)
self.connectionLabel = QtWidgets.QLabel(parent=Form)
self.connectionLabel.setText("")
self.connectionLabel.setObjectName("connectionLabel")
self.gridLayout_2.addWidget(self.connectionLabel, 2, 1, 1, 1)
self.gridLayout_2.addWidget(self.connectionLabel, 1, 1, 1, 1)
self.label_10 = QtWidgets.QLabel(parent=Form)
self.label_10.setObjectName("label_10")
self.gridLayout_2.addWidget(self.label_10, 1, 0, 1, 1)
self.verticalLayout_2.addLayout(self.gridLayout_2)
self.label_3 = QtWidgets.QLabel(parent=Form)
self.connectButton = QtWidgets.QPushButton(parent=Form)
self.connectButton.setObjectName("connectButton")
self.verticalLayout_2.addWidget(self.connectButton)
self.titletypeLabel = QtWidgets.QLabel(parent=Form)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.verticalLayout_2.addWidget(self.label_3)
self.titletypeLabel.setFont(font)
self.titletypeLabel.setObjectName("titletypeLabel")
self.verticalLayout_2.addWidget(self.titletypeLabel)
self.comboBox = QtWidgets.QComboBox(parent=Form)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.verticalLayout_2.addWidget(self.comboBox)
self.label_4 = QtWidgets.QLabel(parent=Form)
self.titlefrequencyLabel = QtWidgets.QLabel(parent=Form)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.verticalLayout_2.addWidget(self.label_4)
self.titlefrequencyLabel.setFont(font)
self.titlefrequencyLabel.setObjectName("titlefrequencyLabel")
self.verticalLayout_2.addWidget(self.titlefrequencyLabel)
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.startEdit = QtWidgets.QLineEdit(parent=Form)
@ -88,39 +90,39 @@ class Ui_Form(object):
self.label_5 = QtWidgets.QLabel(parent=Form)
self.label_5.setObjectName("label_5")
self.gridLayout.addWidget(self.label_5, 0, 0, 1, 1)
self.verticalLayout_2.addLayout(self.gridLayout)
self.pushButton_2 = QtWidgets.QPushButton(parent=Form)
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout.addWidget(self.pushButton_2, 2, 1, 1, 1)
self.verticalLayout_2.addLayout(self.gridLayout)
self.verticalLayout_2.addWidget(self.pushButton_2)
self.pushButton_3 = QtWidgets.QPushButton(parent=Form)
self.pushButton_3.setObjectName("pushButton_3")
self.verticalLayout_2.addWidget(self.pushButton_3)
self.label_9 = QtWidgets.QLabel(parent=Form)
self.titleinfoLabel = QtWidgets.QLabel(parent=Form)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_9.setFont(font)
self.label_9.setObjectName("label_9")
self.verticalLayout_2.addWidget(self.label_9)
self.titleinfoLabel.setFont(font)
self.titleinfoLabel.setObjectName("titleinfoLabel")
self.verticalLayout_2.addWidget(self.titleinfoLabel)
self.scrollArea = QtWidgets.QScrollArea(parent=Form)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 273, 231))
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 273, 229))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.verticalLayout_2.addWidget(self.scrollArea)
self.horizontalLayout_2.addLayout(self.verticalLayout_2)
self.verticalLayout_5 = QtWidgets.QVBoxLayout()
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.S11 = MplWidget(parent=Form)
self.S11Plot = MplWidget(parent=Form)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.S11.sizePolicy().hasHeightForWidth())
self.S11.setSizePolicy(sizePolicy)
self.S11.setObjectName("S11")
self.verticalLayout_5.addWidget(self.S11)
sizePolicy.setHeightForWidth(self.S11Plot.sizePolicy().hasHeightForWidth())
self.S11Plot.setSizePolicy(sizePolicy)
self.S11Plot.setObjectName("S11Plot")
self.verticalLayout_5.addWidget(self.S11Plot)
self.horizontalLayout_2.addLayout(self.verticalLayout_5)
self.horizontalLayout_2.setStretch(1, 1)
@ -130,18 +132,20 @@ class Ui_Form(object):
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label_2.setText(_translate("Form", "Connection Settings:"))
self.label.setText(_translate("Form", "Port:"))
self.connectButton.setText(_translate("Form", "Connect"))
self.titleconnectionLabel.setText(_translate("Form", "Connection Settings:"))
self.refreshButton.setText(_translate("Form", "Refresh"))
self.label.setText(_translate("Form", "Port:"))
self.label_10.setText(_translate("Form", "Connected to:"))
self.label_3.setText(_translate("Form", "T&M Type:"))
self.label_4.setText(_translate("Form", "Frequency Sweep:"))
self.connectButton.setText(_translate("Form", "Connect"))
self.titletypeLabel.setText(_translate("Form", "T&M Type:"))
self.comboBox.setItemText(0, _translate("Form", "Mechanical"))
self.comboBox.setItemText(1, _translate("Form", "Electrical"))
self.titlefrequencyLabel.setText(_translate("Form", "Frequency Sweep:"))
self.label_8.setText(_translate("Form", "MHz"))
self.label_6.setText(_translate("Form", "MHz"))
self.label_7.setText(_translate("Form", "Stop Frequency:"))
self.label_5.setText(_translate("Form", "Start Frequency:"))
self.pushButton_2.setText(_translate("Form", "Start Sweep"))
self.pushButton_3.setText(_translate("Form", "T&M Settings"))
self.label_9.setText(_translate("Form", "Info Box:"))
self.titleinfoLabel.setText(_translate("Form", "Info Box:"))
from nqrduck.contrib.mplwidget import MplWidget