473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 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 1690
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

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

Similar topics

1
by: Rick | last post by:
After being frustrated with this issue on several occasions I think I found the secret sauce for solving the issue after reading a few different messages about what others thought and trying a...
3
by: ewitkop90 | last post by:
Here is my code: <SCRIPT> function transportchange(transport) { if (framenewinstall.Helpdesk.checked) framenewinstall.Helpdesk.checked=false; if (framenewinstall.CircuitNumber.checked)...
0
by: SenthilVel | last post by:
Hi i have radio buttons in my Page and i am able to see some starnge behaviour with those. 1st : DSN 2nd radio button: MSDE the above 2 are in collection.
2
by: SenthilVel | last post by:
Hi i have radio buttons in my Page and i am able to see some starnge behaviour with those. 1st : DSN 2nd radio button: MSDE the above 2 are in collection.
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
1
by: Joe Attardi | last post by:
Hi all, On a form on one of my pages I have two <select> elements, and each one is paired up with a radio button. The idea is to choose an item from one list or the other and select the radio...
3
by: Harry Haller | last post by:
I have a radio button group. When the page loads none of them are selected. OnClick selects ONE and clicking another one selects a different one - this is normal behavior. I want to modify it so...
4
by: Z.K. | last post by:
I started a forms application and I put on the form three buttons. In the functions for the radio buttons I put in a single messagebox like: MessageBox("Hello 1") MessageBox("Hello 2") ...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
1
by: avinash sh | last post by:
i have radio type html control....i select on radio button and click on select button it is redirected to next page...if i click on back button again i back on radio button page... then one of the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.