Hi Mick,
Sorry about that. Here is the simplest example, which fails:
import Tkinter as tk
import tkSimpleDialog
def edit_preferences(event=None):
prefs = Preferences(master, title="Preferences")
class Preferences(tkSimpleDialog.Dialog):
def body(self, master):
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 = tk.Tk()
tk.Button(master, text="Prefs", command=edit_preferences).grid()
master.mainloop()
Thanks for your help,
Iain
Michael O'Donnell wrote:
Hi Iain,
My earlier reply established that the radio widget IS functioning correctly
on your machine in the usual case. If there is still something wrong, I'd have
to see runnable code from your app which fails to set the radio. Can you
make a minimal case which uses the class structure you discuss, and
still doesn't work, and send it (probably as a compressed archive,
e.g., zip file).
I'll then see if I can find the bug. What OS are you on?
Mick
On Sat, Aug 16, 2008 at 9:34 PM, Iain Day
<[EMAIL PROTECTED]> wrote:
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
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss