tkinter radiobutton

Eric Brunel eric_brunel at
Mon Jun 27 08:49:33 CEST 2005

On Sat, 25 Jun 2005 19:34:50 GMT, William Gill <noreply at> wrote:

> I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep
> references to them in a 2 dimensional list ( rBtns[r][c] ).  It works
> fine, and I can even make it so only one button per column can be
> selected, by assigning each column to an intVar.  In many languages a
> radiobutton has a property that can be directly read to see if it is
> selected on unselected.  Tkinter radiobuttons don't seem to have any
> such property.  Is there any way to look (via the script not the screen)
> to determine if it is selected?, or can this only be achieved via
> control variables?

The value and variable options for a radiobutton seem to be what you're looking for. Here is an example showing how to use them:

 from Tkinter import *

root = Tk()
v = StringVar()
Radiobutton(root, text='foo', value='foo', variable=v).pack()
Radiobutton(root, text='bar', value='bar', variable=v).pack()

def p():
   print v.get()

Button(root, command=p, text='Print').pack()


python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])"

More information about the Python-list mailing list