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
- onRadio = Radiobutton(onOff, text = "On", value = 0, variable = v)
-
onRadio.pack(side = BOTTOM, anchor = S)
-
onRadio.select()
This should select the onRadio but it doesnt.
- v = StringVar()
-
v.set("On") # or whatever you want the default to be
-
onRadio = Radiobutton(onOff, text = "On", value = 0, variable = v)
-
onRadio.pack(side = BOTTOM, anchor = S)
-
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.