radio button again!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vajratkarviraj
    New Member
    • Jun 2007
    • 15

    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
  • vajratkarviraj
    New Member
    • Jun 2007
    • 15

    #2
    anybody??? nobody's got a solution?? the main difficulty i am facing is how to effectively use button.configur e(state=NORMAL) or button.configur e(state=DISABLE D)... help will really be appreciated guys... thanks...

    Comment

    • dazzler
      New Member
      • Nov 2007
      • 75

      #3
      [code=python]
      master = Tk()

      def radiobutton_com mand():
      if radiobutton_var .get() == 1:
      radiobutton_2["state"] = NORMAL
      radiobutton_4["state"] = DISABLED

      if radiobutton_var .get() == 2:
      pass

      if radiobutton_var .get() == 3:
      radiobutton_2["state"] = DISABLED
      radiobutton_4["state"] = NORMAL

      if radiobutton_var .get() == 4:
      pass

      radiobutton_var = IntVar()

      radiobutton_1 = Radiobutton(mas ter, text="Button 1", variable=radiob utton_var, value=1, command=radiobu tton_command)
      radiobutton_1.p lace(x=0, y=0)
      radiobutton_2 = Radiobutton(mas ter, text="Button 2", variable=radiob utton_var, value=2, command=radiobu tton_command)
      radiobutton_2.p lace(x=0, y=0)
      radiobutton_3 = Radiobutton(mas ter, text="Button 3", variable=radiob utton_var, value=3, command=radiobu tton_command)
      radiobutton_3.p lace(x=0, y=0)
      radiobutton_4 = Radiobutton(mas ter, text="Button 4", variable=radiob utton_var, value=4, command=radiobu tton_command)
      radiobutton_4.p lace(x=0, y=0)

      master.mainloop ()
      [/code]

      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...

      Comment

      Working...