Linking Radio Button from one Group to another in if statement

I am Trying to add the action of a radio button getting clicked in one group to a radio Button getting clicked in another group.
Eg : Radia A and Radio B ----> Group 1
Radio X and Radio Y ------>Group2
Clicking Radio A and then Radio X will give a particular placeholder text.
Similar for Radio A —> Radio Y , Radio B —> Radio X and Radio B —> Radio Y

I have used the following code:

def Pb_button_clicked(self, **event_args): ------->Radio X

for radio in self.column_panel_2.get_components():
  A= self.SI_button_clicked()     -------->Radio A
  B= self.Field_units_clicked()    -------->Radio B

  if A == True :
    self.text_box_Pb_Rsb.placeholder="Enter Pb in psia"
  elif B==True:
    self.text_box_Pb_Rsb.placeholder="Enter Pb in psia"
  else:
    self.text_box_Pb_Rsb.placeholder="Enter Pb "

pass

Similarly for Radio Y ( only placeholder text would change)

In my case , it is not reading the conditions. When I click Radio A and Radio X it only shows the else text ‘Enter Pb’ not the other options.

self.column_panel_2 is the column panel inside which Group 1 Radio buttons are stored

Welcome to the forum!

Radio buttons have a change event you can handle to adjust things as values change.

Thank you , Will look into this

Would it be possible to link some information regarding this. I cannot seem to find it.

I made it work by using
A= self.SI_button.selected
B= self.Field_units.selected
instead of clicked,
But they do not change back when shifting between Radio A and Radio B . It is only a one time click.
ANy help with automating this ?

Look in the properties for the radio button. The event is called clicked instead of change, but it’s the same idea. The function attached to that event fires every time the radio button is clicked.

If you’re not familiar with event handlers, there’s a tutorial that walks through setting one up for a drop down. The process is the same for all components. Anvil | Respond to user input

2 Likes