By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,985 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,985 IT Pros & Developers. It's quick & easy.

radio button again!

P: 15
Hi,
Am using Tkinter. Suppose I have 4 radio buttons (value 1,2,3 & 4) arranged in a single column. I want radio 2 to have a normal state and radio 4 to have a disabled state when radio 1 is selected. And radio 2 - disabled, radio 4 - normal when radio 3 is selected (i.e. vice versa). My main question here is how do i get to know the state(i.e. normal or disabled) of a radio button as a feedback? thanx in advance
Dec 5 '07 #1
Share this Question
Share on Google+
2 Replies


P: 15
anybody??? nobody's got a solution?? the main difficulty i am facing is how to effectively use button.configure(state=NORMAL) or button.configure(state=DISABLED)... help will really be appreciated guys... thanks...
Dec 5 '07 #2

P: 75
Expand|Select|Wrap|Line Numbers
  1. master = Tk()
  2.  
  3. def radiobutton_command():
  4.    if radiobutton_var.get() == 1:
  5.       radiobutton_2["state"] = NORMAL
  6.       radiobutton_4["state"] = DISABLED
  7.  
  8.    if radiobutton_var.get() == 2:
  9.       pass
  10.  
  11.    if radiobutton_var.get() == 3:
  12.       radiobutton_2["state"] = DISABLED
  13.       radiobutton_4["state"] = NORMAL
  14.  
  15.    if radiobutton_var.get() == 4:
  16.       pass
  17.  
  18. radiobutton_var = IntVar()
  19.  
  20. radiobutton_1 = Radiobutton(master, text="Button 1", variable=radiobutton_var, value=1, command=radiobutton_command)
  21. radiobutton_1.place(x=0, y=0)
  22. radiobutton_2 = Radiobutton(master, text="Button 2", variable=radiobutton_var, value=2, command=radiobutton_command)
  23. radiobutton_2.place(x=0, y=0)
  24. radiobutton_3 = Radiobutton(master, text="Button 3", variable=radiobutton_var, value=3, command=radiobutton_command)
  25. radiobutton_3.place(x=0, y=0)
  26. radiobutton_4 = Radiobutton(master, text="Button 4", variable=radiobutton_var, value=4, command=radiobutton_command)
  27. radiobutton_4.place(x=0, y=0)
  28.  
  29. master.mainloop()
  30.  
ofcourse you must add more state changes for each radiobutton, for example if you press radiobutton1 and then button2, the state of button4 stays disabled...
Dec 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.