473,480 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Radio Buttons

208 New Member
I have two radiobuttons: onRadio and offRadio....When 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 6013
bartonc
6,596 Recognized Expert Expert
I have two radiobuttons: onRadio and offRadio....When 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 programmatically 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 programmatically 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
6124
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...
2
3116
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...
4
3243
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>...
6
3253
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 ...
2
5408
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...
2
11919
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...
1
6837
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...
2
5876
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...
4
2500
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...
11
2253
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...
0
7039
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,...
0
7080
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...
1
6735
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...
0
5326
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4770
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...
0
4476
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...
0
2992
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1296
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 ...
0
176
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...

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.