Public Access
fix: replace ComboBoxText.set_active_text() with model-based lookup
Build Debian Packages / build (trixie, debian13) (push) Successful in 13m8s
Build Debian Packages / build (bookworm, debian12) (push) Successful in 13m13s
Build Debian Packages / build (trixie, debian13) (pull_request) Successful in 13m14s
Build Debian Packages / build (bookworm, debian12) (pull_request) Successful in 13m53s
Build Debian Packages / build (bullseye, debian11) (push) Has been cancelled
Build Debian Packages / build (bullseye, debian11) (pull_request) Has been cancelled
Build Debian Packages / build (trixie, debian13) (push) Successful in 13m8s
Build Debian Packages / build (bookworm, debian12) (push) Successful in 13m13s
Build Debian Packages / build (trixie, debian13) (pull_request) Successful in 13m14s
Build Debian Packages / build (bookworm, debian12) (pull_request) Successful in 13m53s
Build Debian Packages / build (bullseye, debian11) (push) Has been cancelled
Build Debian Packages / build (bullseye, debian11) (pull_request) Has been cancelled
set_active_text() does not exist in GTK 3.24.x (only in GTK 4.x). When loading a saved config with temperature_controller_type='simulated', the set() method crashed on startup with AttributeError. Added _set_combo_active_text() helper that iterates the model to find the matching entry and calls set_active(index) instead.
This commit is contained in:
@@ -2396,7 +2396,7 @@ pygobject version %(pygobject)s
|
||||
try:
|
||||
controller_type = config["temperature_controller_type"]
|
||||
if controller_type in ["eurotherm", "simulated"]:
|
||||
self.config_temp_controller_type_combobox.set_active_text(controller_type)
|
||||
self._set_combo_active_text(self.config_temp_controller_type_combobox, controller_type)
|
||||
# Update widget visibility based on type
|
||||
self._update_temp_widgets_visibility()
|
||||
except (TypeError, ValueError):
|
||||
@@ -2410,7 +2410,7 @@ pygobject version %(pygobject)s
|
||||
try:
|
||||
baudrate = str(config["temperature_baudrate"])
|
||||
if baudrate in ["9600", "19200", "38400", "57600", "115200"]:
|
||||
self.config_temp_baudrate_combobox.set_active_text(baudrate)
|
||||
self._set_combo_active_text(self.config_temp_baudrate_combobox, baudrate)
|
||||
else:
|
||||
self.config_temp_baudrate_combobox.set_active(0) # Default to 19200
|
||||
except (TypeError, ValueError):
|
||||
@@ -2496,6 +2496,24 @@ pygobject version %(pygobject)s
|
||||
else:
|
||||
self.config_temp_baudrate_hbox.hide()
|
||||
|
||||
def _set_combo_active_text(self, combobox, text):
|
||||
"""
|
||||
Set a ComboBoxText's active entry by text.
|
||||
|
||||
Gtk.ComboBoxText.set_active_text() does not exist in GTK 3.24.x,
|
||||
so we iterate the model to find the matching entry.
|
||||
"""
|
||||
if not text:
|
||||
return
|
||||
model = combobox.get_model()
|
||||
if model is None:
|
||||
return
|
||||
for i in range(model.iter_n_children(None)):
|
||||
iter = model.iter_nth_child(None, i)
|
||||
if iter and model.get(iter, 0)[0] == text:
|
||||
combobox.set_active(i)
|
||||
return
|
||||
|
||||
def load_config_handler( self, widget ):
|
||||
if self.system_default_filename:
|
||||
self.load_config( self.system_default_filename )
|
||||
|
||||
Reference in New Issue
Block a user