On Sat, 04 Dec 2004 14:38:06 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Mark Kels wrote:
> 
> 
> > 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()
> 
> This program works fine for me on Win2K. How are you running the program?
> >
> > 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?
> 
> Read the value from the variable associated with the buttons - v. For example 
> if you define
> def quit():
>      print 'You chose button', v.get()
>      f.quit()
> 
> and change the command on bb to command=quit, the program will print the 
> selection value on exit.
> (You have to define quit before bb or you will get a NameError.)
> 
> Kent
> >
> > Thanks!!
> > _______________________________________________
> > Tutor maillist  -  [EMAIL PROTECTED]
> > http://mail.python.org/mailman/listinfo/tutor
> >
> _______________________________________________
> Tutor maillist  -  [EMAIL PROTECTED]
> http://mail.python.org/mailman/listinfo/tutor
> 

Thats weird...
Suddenly the program started to work fine :-) !

Thank you very much for your time.
_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to