Thanks for the reply. Unfortunately, even when I include a
variable, all of the buttons start out selected. I noticed that this is the
case when I create a StringVar (rather than an IntVar, where the buttons start
out correctly unselected). So, here's another simple example where all of the
radio buttons start out incorrectly selected:
from tkinter import *
root = Tk()
root.grid()
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)
root.mainloop()
Any ideas on how to have a StringVar() associated with a group of Radiobutton
objects where all of the radio buttons start off unselected?
--Bob
> Date: Thu, 8 Oct 2009 20:43:21 -0400
> Subject: Re: [Tutor] Python 3 and tkinter Radiobuttons
> From: ken...@tds.net
> To: bobsmith...@hotmail.com
> CC: tutor@python.org
>
> On Thu, Oct 8, 2009 at 6:04 PM, bob smith <bobsmith...@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()
> root.grid()
> 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)
>
> root.mainloop()
>
>
> Kent
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor