[Tutor] Broblem with exiting a Tkinter app

Mark Kels mark.kels at gmail.com
Sat Dec 4 17:19:28 CET 2004


Hi all ,
I got 2 questions for you guys.

The fist question:
I wrote small Tkinter app while laerning about the Radiobutton widget,
and I added a "Quit" button, like this:
bb=Button(root, text="Quit", fg="BLUE", command=root.quit).pack()
When I pressed the button the app crashed and I got an error message (
program is not responding ) from windows.
I tried to add a frame to the program and then exit the frame, like this:
bb=Button(f, text="Quit", fg="BLUE", command=f.quit).pack()
But the result is the same...

Here is the full source code of the app:
from Tkinter import *
import sys
root=Tk()
f=Frame(root)
text=Label(root, text="how old are you?").pack()
v = IntVar(root)
Radiobutton(f, text="less than 13", variable=v, value=1).pack(side=LEFT)
Radiobutton(f, text="13-20", variable=v, value=2).pack(side=LEFT)
Radiobutton(f, text="20-40", variable=v, value=3).pack(side=LEFT)
Radiobutton(f, text="40+", variable=v, value=4).pack(side=LEFT)
bb=Button(f, text="Quit", fg="BLUE", command=f.quit).pack()
f.pack()
root.mainloop()

The second question:
I dont understand how to get the input fron the radio buttons...
It doesnt returns any value, so how can the app know what the user chose?

Thanks!!


More information about the Tutor mailing list