473,606 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Radio Buttons

208 New Member
I have two radiobuttons: onRadio and offRadio....Whe n the program loads I want the onRadio button to be selected. How do I do this?

I've tried:
onRadio.select( ) but this does nothing.
Mar 9 '07 #1
6 6017
bartonc
6,596 Recognized Expert Expert
I have two radiobuttons: onRadio and offRadio....Whe n the program loads I want the onRadio button to be selected. How do I do this?

I've tried:
onRadio.select( ) but this does nothing.
Depends on which GUI Toolkit you're using. I see that you are a .NETer; new to python?
Mar 9 '07 #2
Silent1Mezzo
208 New Member
Depends on which GUI Toolkit you're using. I see that you are a .NETer; new to python?
New to python. Experienced at .NET

I'm using the TK GUI toolkit
Mar 9 '07 #3
bartonc
6,596 Recognized Expert Expert
New to python. Experienced at .NET

I'm using the TK GUI toolkit
That would be "Tkinter" in python.
To group radio buttons in Tkinter you must associate something I like to call a Tk PyVar. This variable (common to all buttons in a group) is automaticly updated when the buttons are push and setting it programmaticall y sets the buttons. It can be an integer or a string.
For info, see this link:
radio button patterns
Mar 9 '07 #4
bartonc
6,596 Recognized Expert Expert
New to python. Experienced at .NET

I'm using the TK GUI toolkit
I'm curious; are you just checking python out; trying to find something easier than .NET; have you heard of MS's IronPython (sort of a marriage between python and .NET, from what I understand)?
Mar 9 '07 #5
Silent1Mezzo
208 New Member
That would be "Tkinter" in python.
To group radio buttons in Tkinter you must associate something I like to call a Tk PyVar. This variable (common to all buttons in a group) is automaticly updated when the buttons are push and setting it programmaticall y sets the buttons. It can be an integer or a string.
For info, see this link:
radio button patterns

I have the radio buttons working my problem is that I need one of them preselected when the program loads....and the .select() isn't working

Expand|Select|Wrap|Line Numbers
  1. onRadio = Radiobutton(onOff, text = "On", value = 0, variable = v)
  2. onRadio.pack(side = BOTTOM, anchor = S)
  3. onRadio.select()
This should select the onRadio but it doesnt.
Mar 9 '07 #6
bartonc
6,596 Recognized Expert Expert
I have the radio buttons working my problem is that I need one of them preselected when the program loads....and the .select() isn't working

Expand|Select|Wrap|Line Numbers
  1. onRadio = Radiobutton(onOff, text = "On", value = 0, variable = v)
  2. onRadio.pack(side = BOTTOM, anchor = S)
  3. onRadio.select()
This should select the onRadio but it doesnt.
Expand|Select|Wrap|Line Numbers
  1. v = StringVar()
  2. v.set("On")  # or whatever you want the default to be
  3. onRadio = Radiobutton(onOff, text = "On", value = 0, variable = v)
  4. onRadio.pack(side = BOTTOM, anchor = S)
  5.  
select() may work on buttons with no variable associated with them, I don't remember. Once you have the variable, use it to control the group. It makes sense since the other buttons need to be informed of the change and act accordingly (and this is ALL that they have in common).

I should point out that Tk is only very basic and useful for cross-platform development (to a point) because it "comes with" most python installations. There are other cross platform Gui ToolKits which do deliver a native look on Windows and *nix and Mac and have much more intuitive contructors and vast library of widgets. The first think most people notice when developing with Tkinter is that there is no ComboBox widget. Some tree widget support and D&D support has be kluged onto it, but if you look at the source code for IDLE, you'll find that the Text widget in Tk never did work very well. It is a good place for beginners to start, but anyone familiar with an overloaded environment like .NET will find it lacking in a hurry.
Mar 9 '07 #7

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

Similar topics

1
6140
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there are no instructions on how to make checkboxes and radio buttons required. I've tried adding these to my form, but I'm having no luck. Anyone know how to add radio buttons and checkboxes using the existing code mentioned on the url? Thank you!
2
3135
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as they want. If they need to add more, they click an "add name" button and the javascript inserts another row of input boxes. Each row should have two radio buttons to indicate sex (M F). When you have multiple text input boxes with the same...
4
3266
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1> <input type="radio" name=p2 value=2> <input type="radio" name=p2 value=3> then a text area and a button:
6
3275
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked The problem i am facing is that i do not know how many yes/no radio groups will be generated
2
5420
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and I want to be able to retrieve the selected value from each of the sets of radio buttons.The names of each group of radio buttons is set by the database and I don't know how to retrieve the values because I don't know the names of these radio...
2
11951
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put them each in a GroupBox. All the examples I saw from the books or from the web show me how to add static radio buttons at design, or dynamically at run time but with fixed radio buttons (like from an array). I need to create radio buttons based...
1
6866
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and grandtotal the costs ready for the selected items to be inserted back to the database. I did something like this before with Checkboxes, but Radio button have to be named the same to maintain their groupings.
2
5884
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on the form by changing the visible state of the radio buttons and labels utilising back and next buttons. E.g. Next button makes current radio buttons and labels invisible and
4
2510
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see all twelve. User2 would see buttons 1-3,10-12 and NOT any others, and so on. Since there are several buttons on the page (each one would run a report for them), is there a way to - in an onclick event for each of the buttons - to...
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:
0
8428
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
8078
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
8299
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...
1
5962
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5456
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
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2442
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1285
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.