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
-12
@@ -365,7 +365,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.checkbox_heater_activate.stateChanged.connect(self.on_checkbox_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.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)
|
||||
# Only meaningful (and only shown) once the server confirms its Pot
|
||||
# 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.doubleSpinBox_heatrate_soll.setEnabled(False)
|
||||
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.warp_factor = 1.0
|
||||
self.sud_elapsed_seconds = None
|
||||
@@ -528,11 +530,15 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
for key in msg:
|
||||
if "AmbientTemp" in key:
|
||||
self.ambient_temp = msg['AmbientTemp']
|
||||
# Only sync the entry's text while the user isn't actively
|
||||
# editing it, so a server echo doesn't clobber in-progress
|
||||
# typing.
|
||||
if not self.lineEdit_ambient.hasFocus():
|
||||
self.lineEdit_ambient.setText("{:.1f}".format(self.ambient_temp))
|
||||
# Only sync the spinbox while the user isn't actively
|
||||
# interacting with it, so a server echo doesn't clobber an
|
||||
# in-progress edit - blockSignals avoids this setValue()
|
||||
# itself re-triggering on_ambient_entry_changed() and
|
||||
# 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:
|
||||
self.warp_factor = msg['WarpFactor']
|
||||
elif "PlantSim" in key:
|
||||
@@ -542,11 +548,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
def on_action_pot_reset(self):
|
||||
self.msg_pot.send({'Reset': True})
|
||||
|
||||
def on_ambient_entry_changed(self):
|
||||
try:
|
||||
value = float(self.lineEdit_ambient.text())
|
||||
except ValueError:
|
||||
return
|
||||
def on_ambient_entry_changed(self, value):
|
||||
self.user_config.set('ambient_temperature', value)
|
||||
self.msg_system.send({'AmbientTemp': value})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user