How To Get A Radiobutton To Work
Im trying to get my RadioButton to work and return something. Well to be a bit clearer I want it to go something like this. The user select 2 Joueur or 3 Joueur, next select Sans o
Solution 1:
I see one problem. Your Radiobutton
s are not connected and you have no way to read their status. Create a Variable
and use that for all Radiobutton
s in the group.
Code from TutorialsPoint:
var = IntVar()
R1 = Radiobutton(root, text="Option 1", variable=var, value=1,
command=sel)
R1.pack( anchor = W )
R2 = Radiobutton(root, text="Option 2", variable=var, value=2,
command=sel)
R2.pack( anchor = W )
R3 = Radiobutton(root, text="Option 3", variable=var, value=3,
command=sel)
R3.pack( anchor = W)
So var
represents the status of the button group. Each button is given a different value so that you can tell which is selected.
Note that each group will need it's own IntVar
. And make sure to keep a reference to the variable by assigning it to an instance variable (i.e. self.var
)
When you want to check the status you use var.get()
.
Post a Comment for "How To Get A Radiobutton To Work"