Init value is None for RadioButton

When I am initializing a RadioButton on the form I can set the selected property from gui or via code. I can then get the value of the RadioButton’s group with get_group_value().

However, at init the RadioButtons value is None, even if I set it as selected in code or from the Gui. This results in a crash since I check the value at the init of the form. The value changes only when the user clicks the RadioButton.

This is not expected behaviour? The radiobutton should have the groups value from init?

I noticed one more thing here: If I create a new Material Design 3 app and add two radiobuttons and select the second one and run the app everything works.

But if I now change so that button1 is selected, the second button is still selected when I run the app.

In my experience, this is a timing issue. get_group_value() is valid only after __init__() has completed, e.g., in the form_show() handler, if you have one. Only then do the radio buttons physically exist, in working form, to be polled by get_group_value().

2 Likes