471,350 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

radio button again!

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
2 1490
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
dazzler
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.

Similar topics

1 post views Thread by Rick | last post: by
reply views Thread by SenthilVel | last post: by
2 posts views Thread by SenthilVel | last post: by
3 posts views Thread by Harry Haller | last post: by
1 post views Thread by avinash sh | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.