I have the following code (in python and tkinter):
c1 = tk.Radiobutton (frm, text='a',variable= radioValue ,value=1)
c2 = tk.Radiobutton (frm, text='b',variable= radioValue ,value=2)
c3 = tk.Radiobutton (frm, text='c',variable= radioValue ,value=3)
c4 = tk.Radiobutton (frm, text='d',variable= radioValue ,value=4)
then I retrieve a value called r from database, it is between 1 and 4.
I use r to set a radio button to on by using many if statements, and it works well. The if statements are:
if (r==1):
(c1.select())
if (r==2):
(c2.select())
if (r==3):
(c3.select())
if (r==4):
(c4.select())
Is there a better solution instead of multiple if?
keyreferring to the radio button of its value then later usegetmethod of the dict.radioValue.set(r).elifafterif. no need to check rest of them