Hi Mick,

Sorry about that. The code below does work, however, in my case its a little more complex. I'll try and explain. I've put most of the code into different modules which get imported in the usual way, so I have one that has all the classes for the menu bar. There is also a class in here which generates the tkSimpleDialog for the preferences. Is is here that I've got the bit of code I posted below.

__main__.angles is set correctly, and if I do:

print tk.StringVar.get(angles)

I get the correct result.

I'm a little confused. Also if I put angles into an Entry widget it is correct.

Thanks for your help,

Iain

Michael O'Donnell wrote:
Dear Iain,

    Makes it easier to test your code if you provide
a standalone example.

I modified your code as follows to get it to run:

import Tkinter as tk
master = tk.Tk()
settings = tk.LabelFrame(master, text="Settings")
settings.grid(row=0, column=0)
tk.Label(settings, text="Angular Units: ").grid(row=0, column=0, sticky=tk.E)
angles = tk.StringVar(value='radians')
tk.Radiobutton(settings, text="Degrees", variable=angles,
value='degrees').grid(row=0, column=1)
tk.Radiobutton(settings, text="Radians", variable=angles,
value='radians').grid(row=0, column=2)
master.mainloop()

...and on my Macosx running python 2.5.2 it runs fine, with buttons selected.

My bet is that angles is not in fact set, or is not set
to one of 'degrees' or 'radians'. Put a print statement to
see what value  __main__.angles has at the point of
setting the variable angles.

Mick



On Fri, Aug 15, 2008 at 6:19 AM, Iain Day
<[EMAIL PROTECTED]> wrote:
Hi,

I'm trying to create a preferences dialog. At the moment, I'm just reading a
config file using ConfigParser and displaying this in a tkSimpleDialog.

I've got some Entry widgets working okay, but I can't get the radiobuttons
to work. The code is:

import Tkinter as tk

settings = tk.LabelFrame(master, text="Settings")
settings.grid(row=0, column=0)

tk.Label(settings, text="Angular Units: ").grid(row=0, column=0,
sticky=tk.E)

angles = tk.StringVar(value=__main__.angles)

tk.Radiobutton(settings, text="Degrees", variable=angles,
value='degrees').grid(row=0, column=1)

tk.Radiobutton(settings, text="Radians", variable=angles,
value='radians').grid(row=0, column=2)

When I run this, angles is set to degrees but I don't get the radiobutton
active (either of them).

What am I doing wrong?

Thanks,

Iain

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to