mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Settings: support arbitrary number of radio button options
This commit is contained in:
@@ -271,12 +271,9 @@ class SettingActivity(Activity):
|
|||||||
ui_options = setting.get("ui_options")
|
ui_options = setting.get("ui_options")
|
||||||
if ui and ui == "radiobuttons" and ui_options:
|
if ui and ui == "radiobuttons" and ui_options:
|
||||||
selected_idx = self.active_radio_index
|
selected_idx = self.active_radio_index
|
||||||
if selected_idx == 0: # only supports 2 options, could be made more generic
|
new_value = ""
|
||||||
new_value = ui_options[0][1]
|
if selected_idx >= 0:
|
||||||
elif selected_idx == 1:
|
new_value = ui_options[selected_idx][1]
|
||||||
new_value = ui_options[1][1]
|
|
||||||
else:
|
|
||||||
return # nothing to save
|
|
||||||
elif ui and ui == "dropdown" and ui_options:
|
elif ui and ui == "dropdown" and ui_options:
|
||||||
selected_index = self.dropdown.get_selected()
|
selected_index = self.dropdown.get_selected()
|
||||||
print(f"selected item: {selected_index}")
|
print(f"selected item: {selected_index}")
|
||||||
|
|||||||
Reference in New Issue
Block a user