473,606 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

radio button again!

15 New Member
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 1705
vajratkarviraj
15 New Member
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...
Dec 5 '07 #2
dazzler
75 New Member
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
6908
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 combination of them all. What worked for me was the following: 1. Put a Break Point in MFC source file DLGDATA.CPP on line 338 which is: TRACE0("Warning: skipping non-radio button in group.\n"); (Copyright
3
2350
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) framenewinstall.CircuitNumber.checked=false; switch (transport) { case 0: Helpdesk.innerText="No Info Needed";
0
1104
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
1688
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
3473
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 "No", he should not have the option of clicking on any of the six checkboxes. See Code attached. Thank you so much in advance for your help as I can't get to make this combo work. <p>Did you have any problems finding any of the information...
1
2969
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 button of the list you want to use. I'm using JavaScript to automatically select the radio button corresponding to a list when you click on the list (using the onclick event handler). Is that the best event to change on, or should this
3
5827
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 that clicking on a radio which is already selected will deselect it so that none of the group are selected. I can get the required behavior with a double-click: ondblclick="this.checked=!(this.checked);"
4
3085
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") MessageBox("Hello 3")
11
2264
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 6.something I think and running as a service, Using NoteTab Pro as an IDE (works well). If you need more, just ask. In one functioning form:
1
1191
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 previous radio button is looking selected... but i click again on select .....it give alert box ..plz select record..? my code is here. var isRadioSeleted=''; function Selected() { isRadioSeleted =...
0
8036
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8448
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8126
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8317
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5470
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1313
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.