Tkinter Radiobutton and askfloat()

Jon Hsieh Jonathan.T.Hsieh at jpl.nasa.gov
Mon May 19 15:09:04 EDT 2003


Hi,
I created a Radiobutton:

> from Tkinter import *
> from tkSimpleDialog import askfloat
> 
> def callme():
>     num = askfloat("askfloat", "float:")
> 
> root = Tk()
> rb = Radiobutton(root, command=callme)
 > rb.pack()
 > root.mainloop()

When this code is run, I get the following exception:

>   File "/usr/lib/python2.2/lib-tk/tkSimpleDialog.py", line 271, in askfloat
>     d = apply(_QueryFloat, (title, prompt), kw)
>   File "/usr/lib/python2.2/lib-tk/tkSimpleDialog.py", line 179, in __init__
>     Dialog.__init__(self, parent, title)
>   File "/usr/lib/python2.2/lib-tk/tkSimpleDialog.py", line 64, in __init__
>     self.grab_set()
>   File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 493, in grab_set
>     self.tk.call('grab', 'set', self._w)
> TclError: grab failed: window not viewable

An askfloat() dialog box is created, but it's nonmodal and doesn't
return its value, though it does the normal tkSimpleDialog checks on
the input value.  Any idea why this is happening?  Is it a Python issue?
I am using Python 2.2.1 on Linux.

Thank you!!

~Jon





More information about the Python-list mailing list