RadioButton.get_group_value fails when form is not shown

I noticed that querying a radio button (group) with

value = self.rb1.get_group_value() 

works when the panel containing the radiobutton is visible, but returns None when the panel is not attached to the main form, ie not visible (but not deleted). This was unexpected, because all other fields retain their value.

workaround:

for rb in [self.rb1, self.rb2, self.rb3]:
  if rb.selected:
      return rb.value

but that is somewhat clumsy.

1 Like

Hi @mjmare,

Could you clarify what you mean when you say the panel is not attached to the main Form? Have you got a simple repro clone link that you can share?

Thanks!

I have a main form that has references to several panels. The panel are added/removed as a component to the main form as required. So the panels are constructed once, but not always “attached” to the main form as a component.
Nothing fancy, similar to lots of demo apps.

By “attached”, I take it you mean that they have not been added to the main form with .add_component()?

Correct. The panels are swapped in and out as needed. The main form’s init has some code like this:

    self.panels = {
      'start': NotLoggedInPanel(),
      'docs': DocumentsPanel(),
      'pat': PatientPanel(),
      'check': CheckPanel(),
    }

Then I have a method that switches the active panel:

  def select_panel(self, name):
    self.content_panel.clear()
    if not self.is_logged_in():
      name = 'start'
    self.content_panel.add_component(self.panels[name])

I ran into the same problem again. This time a form embedded in an alert. When the alert returns the get_group_value() fails.

I can reproduce.
Moving this to bug reports

1 Like