[Tkinter-discuss] Radiobutton issue
Bob Greschke
bob at passcal.nmt.edu
Wed Dec 6 17:29:41 CET 2006
From: G G
To: tkinter-discuss at python.org
Sent: Wednesday, December 06, 2006 7:13 AM
Subject: [Tkinter-discuss] Radiobutton issue
I was trying to disable Radiobutton widget, with passing
Tkinter.Radiobutton(...,state='disabled') . also tried
Tkinter.Radiobutton(...,state=Tkinter.DISABLED) and
Tkinter.Radiobutton(...,state=DISABLED) and but no success. In first two
cases there is no error message but radiobutton doesn't get disabled...
In the third case I got Python error saying DISABLED is not defined.
Is there any known issue/problem with disabling Radiobutton widget?
thanks a lot
======
It sounds like you may not be importing Tkinter in the "usual" way.
from Tkinter import *
is what I usually use and then things like state=DISABLED will work.
from Tkinter import *
Root = Tk()
RadButVar = StringVar()
RadButVar.set("2") <- set to which button should be initially "on" if any
Rb1 = Radiobutton(Root, text = "TestBut1", variable = RadButVar, value =
"1")
Rb1.pack()
Rb2 = Radiobutton(Root, text = "TestBut2", variable = RadButVar, value =
"2")
Rb2.pack()
Root.mainloop()
The above works and I can put state=DISABLED in either or both of the
Radiobutton lines and get predictable results.
I can also do things like Rb2.config(state = DISABLED) later in the
program and it works, however, if a radiobutton is selected when you change
the state to DISABLED it will stay selected until the user selects another
one of the associated radiobuttons.
Bob
More information about the Tkinter-discuss
mailing list