[Tutor] Python 3 and tkinter Radiobuttons

Alan Gauld alan.gauld at btinternet.com
Sun Oct 11 08:04:16 CEST 2009

"bob smith" <bobsmith327 at hotmail.com> wrote

> So, here's another simple example where all of the radio buttons
> start out incorrectly selected:

    v = StringVar()
    Radiobutton(root, text = "Test RadioButton 1", variable=v, 
value="1").grid(row = 0, column = 0, sticky = W)
    Radiobutton(root, text = "Test RadioButton 2", variable=v, 
value="2").grid(row = 1, column = 0, sticky = W)
> Any ideas on how to have a StringVar() associated with a
> group of Radiobutton objects where all of the radio buttons start off 
> unselected?

Don't you need to assign a value to the StringVar? Othewise how does Python
know which of your buttons is supposed to be the selected option?

But I'm no expert, I rarely use radio buttons...

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list