GUI: use a spinbox for ambient temperature instead of a text entry
Replaces lineEdit_ambient (QLineEdit) with doubleSpinBox_ambient (QDoubleSpinBox, 0-50 degC, 0.5 deg steps) in brewpi.ui, regenerated main_window.py via pyuic5 (same generator version, verified minimal diff). brewpi_gui.py wires valueChanged instead of returnPressed - no more manual float()/ValueError parsing of typed text, the signal already hands over a valid float - with blockSignals guards around server-driven updates (mirroring the existing doubleSpinBox_heatrate_soll pattern) so applying a server echo doesn't immediately re-send the same value back. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DkkuG48uHFCGKe6dPSERFk
This commit is contained in:
+14
-2
@@ -3714,7 +3714,7 @@
|
|||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_ambient">
|
<widget class="QDoubleSpinBox" name="doubleSpinBox_ambient">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>620</x>
|
<x>620</x>
|
||||||
@@ -3724,7 +3724,19 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Set the simulated/assumed ambient temperature - press Enter to apply</string>
|
<string>Set the simulated/assumed ambient temperature</string>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<double>0.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>50.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.500000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="btn_pot_reset">
|
<widget class="QPushButton" name="btn_pot_reset">
|
||||||
|
|||||||
+14
-12
@@ -365,7 +365,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
self.checkbox_heater_activate.stateChanged.connect(self.on_checkbox_changed)
|
self.checkbox_heater_activate.stateChanged.connect(self.on_checkbox_changed)
|
||||||
self.checkbox_stirrer_activate.stateChanged.connect(self.on_checkbox_stirrer_activate_changed)
|
self.checkbox_stirrer_activate.stateChanged.connect(self.on_checkbox_stirrer_activate_changed)
|
||||||
self.checkbox_tc_enable.stateChanged.connect(self.on_checkbox_tc_enable_changed)
|
self.checkbox_tc_enable.stateChanged.connect(self.on_checkbox_tc_enable_changed)
|
||||||
self.lineEdit_ambient.returnPressed.connect(self.on_ambient_entry_changed)
|
self.doubleSpinBox_ambient.valueChanged.connect(self.on_ambient_entry_changed)
|
||||||
self.btn_pot_reset.clicked.connect(self.on_action_pot_reset)
|
self.btn_pot_reset.clicked.connect(self.on_action_pot_reset)
|
||||||
# Only meaningful (and only shown) once the server confirms its Pot
|
# Only meaningful (and only shown) once the server confirms its Pot
|
||||||
# is simulated - see on_system_changed()'s "PlantSim" handling.
|
# is simulated - see on_system_changed()'s "PlantSim" handling.
|
||||||
@@ -494,7 +494,9 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
self.Slider_temp_soll.setEnabled(False)
|
self.Slider_temp_soll.setEnabled(False)
|
||||||
self.doubleSpinBox_heatrate_soll.setEnabled(False)
|
self.doubleSpinBox_heatrate_soll.setEnabled(False)
|
||||||
self.ambient_temp = None
|
self.ambient_temp = None
|
||||||
self.lineEdit_ambient.clear()
|
self.doubleSpinBox_ambient.blockSignals(True)
|
||||||
|
self.doubleSpinBox_ambient.setValue(self.doubleSpinBox_ambient.minimum())
|
||||||
|
self.doubleSpinBox_ambient.blockSignals(False)
|
||||||
self.btn_pot_reset.setVisible(False)
|
self.btn_pot_reset.setVisible(False)
|
||||||
self.warp_factor = 1.0
|
self.warp_factor = 1.0
|
||||||
self.sud_elapsed_seconds = None
|
self.sud_elapsed_seconds = None
|
||||||
@@ -528,11 +530,15 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
for key in msg:
|
for key in msg:
|
||||||
if "AmbientTemp" in key:
|
if "AmbientTemp" in key:
|
||||||
self.ambient_temp = msg['AmbientTemp']
|
self.ambient_temp = msg['AmbientTemp']
|
||||||
# Only sync the entry's text while the user isn't actively
|
# Only sync the spinbox while the user isn't actively
|
||||||
# editing it, so a server echo doesn't clobber in-progress
|
# interacting with it, so a server echo doesn't clobber an
|
||||||
# typing.
|
# in-progress edit - blockSignals avoids this setValue()
|
||||||
if not self.lineEdit_ambient.hasFocus():
|
# itself re-triggering on_ambient_entry_changed() and
|
||||||
self.lineEdit_ambient.setText("{:.1f}".format(self.ambient_temp))
|
# echoing the same value straight back.
|
||||||
|
if not self.doubleSpinBox_ambient.hasFocus():
|
||||||
|
self.doubleSpinBox_ambient.blockSignals(True)
|
||||||
|
self.doubleSpinBox_ambient.setValue(self.ambient_temp)
|
||||||
|
self.doubleSpinBox_ambient.blockSignals(False)
|
||||||
elif "WarpFactor" in key:
|
elif "WarpFactor" in key:
|
||||||
self.warp_factor = msg['WarpFactor']
|
self.warp_factor = msg['WarpFactor']
|
||||||
elif "PlantSim" in key:
|
elif "PlantSim" in key:
|
||||||
@@ -542,11 +548,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
def on_action_pot_reset(self):
|
def on_action_pot_reset(self):
|
||||||
self.msg_pot.send({'Reset': True})
|
self.msg_pot.send({'Reset': True})
|
||||||
|
|
||||||
def on_ambient_entry_changed(self):
|
def on_ambient_entry_changed(self, value):
|
||||||
try:
|
|
||||||
value = float(self.lineEdit_ambient.text())
|
|
||||||
except ValueError:
|
|
||||||
return
|
|
||||||
self.user_config.set('ambient_temperature', value)
|
self.user_config.set('ambient_temperature', value)
|
||||||
self.msg_system.send({'AmbientTemp': value})
|
self.msg_system.send({'AmbientTemp': value})
|
||||||
|
|
||||||
|
|||||||
@@ -1237,9 +1237,13 @@ class Ui_MainWindow(object):
|
|||||||
self.label_ambient.setGeometry(QtCore.QRect(520, 500, 91, 31))
|
self.label_ambient.setGeometry(QtCore.QRect(520, 500, 91, 31))
|
||||||
self.label_ambient.setAlignment(QtCore.Qt.AlignCenter)
|
self.label_ambient.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
self.label_ambient.setObjectName("label_ambient")
|
self.label_ambient.setObjectName("label_ambient")
|
||||||
self.lineEdit_ambient = QtWidgets.QLineEdit(self.centralwidget)
|
self.doubleSpinBox_ambient = QtWidgets.QDoubleSpinBox(self.centralwidget)
|
||||||
self.lineEdit_ambient.setGeometry(QtCore.QRect(620, 500, 70, 31))
|
self.doubleSpinBox_ambient.setGeometry(QtCore.QRect(620, 500, 70, 31))
|
||||||
self.lineEdit_ambient.setObjectName("lineEdit_ambient")
|
self.doubleSpinBox_ambient.setDecimals(1)
|
||||||
|
self.doubleSpinBox_ambient.setMinimum(0.0)
|
||||||
|
self.doubleSpinBox_ambient.setMaximum(50.0)
|
||||||
|
self.doubleSpinBox_ambient.setSingleStep(0.5)
|
||||||
|
self.doubleSpinBox_ambient.setObjectName("doubleSpinBox_ambient")
|
||||||
self.btn_pot_reset = QtWidgets.QPushButton(self.centralwidget)
|
self.btn_pot_reset = QtWidgets.QPushButton(self.centralwidget)
|
||||||
self.btn_pot_reset.setGeometry(QtCore.QRect(700, 500, 220, 31))
|
self.btn_pot_reset.setGeometry(QtCore.QRect(700, 500, 220, 31))
|
||||||
self.btn_pot_reset.setObjectName("btn_pot_reset")
|
self.btn_pot_reset.setObjectName("btn_pot_reset")
|
||||||
@@ -1314,7 +1318,7 @@ class Ui_MainWindow(object):
|
|||||||
self.plainTextUri.setPlainText(_translate("MainWindow", "ws://localhost:8765"))
|
self.plainTextUri.setPlainText(_translate("MainWindow", "ws://localhost:8765"))
|
||||||
self.btn_connect.setText(_translate("MainWindow", "Connect"))
|
self.btn_connect.setText(_translate("MainWindow", "Connect"))
|
||||||
self.label_ambient.setText(_translate("MainWindow", "Ambient [°C]"))
|
self.label_ambient.setText(_translate("MainWindow", "Ambient [°C]"))
|
||||||
self.lineEdit_ambient.setToolTip(_translate("MainWindow", "Set the simulated/assumed ambient temperature - press Enter to apply"))
|
self.doubleSpinBox_ambient.setToolTip(_translate("MainWindow", "Set the simulated/assumed ambient temperature"))
|
||||||
self.btn_pot_reset.setToolTip(_translate("MainWindow", "Only available when the server\'s Pot is simulated"))
|
self.btn_pot_reset.setToolTip(_translate("MainWindow", "Only available when the server\'s Pot is simulated"))
|
||||||
self.btn_pot_reset.setText(_translate("MainWindow", "Pot reset to ambient temperature"))
|
self.btn_pot_reset.setText(_translate("MainWindow", "Pot reset to ambient temperature"))
|
||||||
self.label_8.setText(_translate("MainWindow", "Host"))
|
self.label_8.setText(_translate("MainWindow", "Host"))
|
||||||
|
|||||||
Reference in New Issue
Block a user