[Tutor] Python 3 and tkinter Radiobuttons

Kent Johnson kent37 at tds.net
Fri Oct 9 02:43:21 CEST 2009

On Thu, Oct 8, 2009 at 6:04 PM, bob smith <bobsmith327 at hotmail.com> wrote:
> Hi.  I’m using Tkinter to create a new Radiobutton in Python 3.  However,
> when I create the button, it starts off looking selected instead of
> unselected (though it behaves correctly like an unselected Radiobutton).  So
> this means when I create a group of Radiobuttons they all look selected when
> my program begins.

You have to associate the Radiobuttons with a variable, for example:

from tkinter import *

root = Tk()
v = IntVar()
button = Radiobutton(root, text = "Test RadioButton", variable=v, value=1)
button.grid(row = 0, column = 0, sticky = W)

button = Radiobutton(root, text = "Test RadioButton2", variable=v, value=2)
button.grid(row = 1, column = 0, sticky = W)



More information about the Tutor mailing list