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: except serial.SerialException as e:
logger.error("Failed to connect to device %s", device) logger.error("Failed to connect to device %s", device)
logger.error(e) logger.error(e)

View file

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

View file

@ -37,6 +37,28 @@ class AutoTMView(ModuleView):
self._ui_form.scrollAreaWidgetContents.setLayout(QVBoxLayout()) self._ui_form.scrollAreaWidgetContents.setLayout(QVBoxLayout())
self._ui_form.scrollAreaWidgetContents.layout().setAlignment(Qt.AlignmentFlag.AlignTop) 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) @pyqtSlot(list)
def on_available_devices_changed(self, available_devices : list) -> None: def on_available_devices_changed(self, available_devices : list) -> None:
"""Update the available devices list in the view. """ """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.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout_2.setObjectName("verticalLayout_2")
self.label_2 = QtWidgets.QLabel(parent=Form) self.titleconnectionLabel = QtWidgets.QLabel(parent=Form)
font = QtGui.QFont() font = QtGui.QFont()
font.setBold(True) font.setBold(True)
font.setWeight(75) font.setWeight(75)
self.label_2.setFont(font) self.titleconnectionLabel.setFont(font)
self.label_2.setObjectName("label_2") self.titleconnectionLabel.setObjectName("titleconnectionLabel")
self.verticalLayout_2.addWidget(self.label_2) self.verticalLayout_2.addWidget(self.titleconnectionLabel)
self.gridLayout_2 = QtWidgets.QGridLayout() self.gridLayout_2 = QtWidgets.QGridLayout()
self.gridLayout_2.setObjectName("gridLayout_2") self.gridLayout_2.setObjectName("gridLayout_2")
self.portBox = QtWidgets.QComboBox(parent=Form) self.portBox = QtWidgets.QComboBox(parent=Form)
self.portBox.setObjectName("portBox") self.portBox.setObjectName("portBox")
self.gridLayout_2.addWidget(self.portBox, 0, 1, 1, 1) 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 = QtWidgets.QLabel(parent=Form)
self.label.setObjectName("label") self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1) 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 = QtWidgets.QLabel(parent=Form)
self.connectionLabel.setText("") self.connectionLabel.setText("")
self.connectionLabel.setObjectName("connectionLabel") 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.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 = QtGui.QFont()
font.setBold(True) font.setBold(True)
font.setWeight(75) font.setWeight(75)
self.label_3.setFont(font) self.titletypeLabel.setFont(font)
self.label_3.setObjectName("label_3") self.titletypeLabel.setObjectName("titletypeLabel")
self.verticalLayout_2.addWidget(self.label_3) self.verticalLayout_2.addWidget(self.titletypeLabel)
self.comboBox = QtWidgets.QComboBox(parent=Form) self.comboBox = QtWidgets.QComboBox(parent=Form)
self.comboBox.setObjectName("comboBox") self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.verticalLayout_2.addWidget(self.comboBox) self.verticalLayout_2.addWidget(self.comboBox)
self.label_4 = QtWidgets.QLabel(parent=Form) self.titlefrequencyLabel = QtWidgets.QLabel(parent=Form)
font = QtGui.QFont() font = QtGui.QFont()
font.setBold(True) font.setBold(True)
font.setWeight(75) font.setWeight(75)
self.label_4.setFont(font) self.titlefrequencyLabel.setFont(font)
self.label_4.setObjectName("label_4") self.titlefrequencyLabel.setObjectName("titlefrequencyLabel")
self.verticalLayout_2.addWidget(self.label_4) self.verticalLayout_2.addWidget(self.titlefrequencyLabel)
self.gridLayout = QtWidgets.QGridLayout() self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout") self.gridLayout.setObjectName("gridLayout")
self.startEdit = QtWidgets.QLineEdit(parent=Form) self.startEdit = QtWidgets.QLineEdit(parent=Form)
@ -88,39 +90,39 @@ class Ui_Form(object):
self.label_5 = QtWidgets.QLabel(parent=Form) self.label_5 = QtWidgets.QLabel(parent=Form)
self.label_5.setObjectName("label_5") self.label_5.setObjectName("label_5")
self.gridLayout.addWidget(self.label_5, 0, 0, 1, 1) 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 = QtWidgets.QPushButton(parent=Form)
self.pushButton_2.setObjectName("pushButton_2") self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout.addWidget(self.pushButton_2, 2, 1, 1, 1) self.verticalLayout_2.addWidget(self.pushButton_2)
self.verticalLayout_2.addLayout(self.gridLayout)
self.pushButton_3 = QtWidgets.QPushButton(parent=Form) self.pushButton_3 = QtWidgets.QPushButton(parent=Form)
self.pushButton_3.setObjectName("pushButton_3") self.pushButton_3.setObjectName("pushButton_3")
self.verticalLayout_2.addWidget(self.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 = QtGui.QFont()
font.setBold(True) font.setBold(True)
font.setWeight(75) font.setWeight(75)
self.label_9.setFont(font) self.titleinfoLabel.setFont(font)
self.label_9.setObjectName("label_9") self.titleinfoLabel.setObjectName("titleinfoLabel")
self.verticalLayout_2.addWidget(self.label_9) self.verticalLayout_2.addWidget(self.titleinfoLabel)
self.scrollArea = QtWidgets.QScrollArea(parent=Form) self.scrollArea = QtWidgets.QScrollArea(parent=Form)
self.scrollArea.setWidgetResizable(True) self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea") self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget() 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.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.verticalLayout_2.addWidget(self.scrollArea) self.verticalLayout_2.addWidget(self.scrollArea)
self.horizontalLayout_2.addLayout(self.verticalLayout_2) self.horizontalLayout_2.addLayout(self.verticalLayout_2)
self.verticalLayout_5 = QtWidgets.QVBoxLayout() self.verticalLayout_5 = QtWidgets.QVBoxLayout()
self.verticalLayout_5.setObjectName("verticalLayout_5") 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 = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.S11.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.S11Plot.sizePolicy().hasHeightForWidth())
self.S11.setSizePolicy(sizePolicy) self.S11Plot.setSizePolicy(sizePolicy)
self.S11.setObjectName("S11") self.S11Plot.setObjectName("S11Plot")
self.verticalLayout_5.addWidget(self.S11) self.verticalLayout_5.addWidget(self.S11Plot)
self.horizontalLayout_2.addLayout(self.verticalLayout_5) self.horizontalLayout_2.addLayout(self.verticalLayout_5)
self.horizontalLayout_2.setStretch(1, 1) self.horizontalLayout_2.setStretch(1, 1)
@ -130,18 +132,20 @@ class Ui_Form(object):
def retranslateUi(self, Form): def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form")) Form.setWindowTitle(_translate("Form", "Form"))
self.label_2.setText(_translate("Form", "Connection Settings:")) self.titleconnectionLabel.setText(_translate("Form", "Connection Settings:"))
self.label.setText(_translate("Form", "Port:"))
self.connectButton.setText(_translate("Form", "Connect"))
self.refreshButton.setText(_translate("Form", "Refresh")) self.refreshButton.setText(_translate("Form", "Refresh"))
self.label.setText(_translate("Form", "Port:"))
self.label_10.setText(_translate("Form", "Connected to:")) self.label_10.setText(_translate("Form", "Connected to:"))
self.label_3.setText(_translate("Form", "T&M Type:")) self.connectButton.setText(_translate("Form", "Connect"))
self.label_4.setText(_translate("Form", "Frequency Sweep:")) 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_8.setText(_translate("Form", "MHz"))
self.label_6.setText(_translate("Form", "MHz")) self.label_6.setText(_translate("Form", "MHz"))
self.label_7.setText(_translate("Form", "Stop Frequency:")) self.label_7.setText(_translate("Form", "Stop Frequency:"))
self.label_5.setText(_translate("Form", "Start Frequency:")) self.label_5.setText(_translate("Form", "Start Frequency:"))
self.pushButton_2.setText(_translate("Form", "Start Sweep")) self.pushButton_2.setText(_translate("Form", "Start Sweep"))
self.pushButton_3.setText(_translate("Form", "T&M Settings")) 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 from nqrduck.contrib.mplwidget import MplWidget