Skip to content

Commit 6cd3ece

Browse files
Settings: support arbitrary number of radio button options
1 parent 0b8a128 commit 6cd3ece

File tree

1 file changed

+3
-6
lines changed
  • internal_filesystem/builtin/apps/com.micropythonos.settings/assets

1 file changed

+3
-6
lines changed

internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,9 @@ def save_setting(self, setting):
271271
ui_options = setting.get("ui_options")
272272
if ui and ui == "radiobuttons" and ui_options:
273273
selected_idx = self.active_radio_index
274-
if selected_idx == 0: # only supports 2 options, could be made more generic
275-
new_value = ui_options[0][1]
276-
elif selected_idx == 1:
277-
new_value = ui_options[1][1]
278-
else:
279-
return # nothing to save
274+
new_value = ""
275+
if selected_idx >= 0:
276+
new_value = ui_options[selected_idx][1]
280277
elif ui and ui == "dropdown" and ui_options:
281278
selected_index = self.dropdown.get_selected()
282279
print(f"selected item: {selected_index}")

0 commit comments

Comments
 (0)