I have a set of radio buttons in the some group generated like this
# in __init__
self.item['selected']=get_db_answer()
...
for value in {'option1': 'option 1 text', 'option2': 'option 2 text'}:
radio_button = RadioButton(text=radios[value],
group_name=radio_group_name,
value=value,
tag=value,
selected=(value==self.item['selected']))
self.column_panel_1.add_component(radio_button)
I use get_group_value to later see which of the option is selected.
The way I select the radio button doesn’t feel in keeping with best practices with CRUD.
Is there a way to use Anvil’s databinding to have one of the options selected based on what is in a database without using the visual editor? Alt, is there a better way to programmatically work with radio buttons?
Should I give up on generating the questions in Python and use the visual editor?
It would be nice if I could somehow do two way data binding to what is selected back to item['selected'] so that all the setting and getting is done through the same binding object.
I could add a on_select event for each radio button, but it would be cleaner if there’s a way to bind group_value to the binding object.
Thanks for pointing that out! After playing around with the new theme, I quite like it. Do you know if it’s possible to switch the theme of an existing app from Material Design 3 to New M3 (Beta)?