Fine Tkinter Question

Mariano Corsunsky core.lists.python at core-sdi.com
Thu Feb 7 18:56:31 CET 2002


Hi there!

I have a Tkinter window which opens a 2nd one in which I want to close it
when you hit the <"Return"> key upon the "Close" button. But..... isn't
working.

Let's see the code:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

from Tkinter import *
def show_child ():
    win=Toplevel()
    win.focus_set()
    win.grab_set()
    Quitter=Button(win,text="Close Me",command=win.destroy)
    Quitter.pack()
    Quitter.focus_set()
    win.bind("<Return>",lambda event,myself=win:myself.destroy)

root=Tk()
Button (root,text="Show",command=show_child).pack()
root.mainloop()

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

   Do you know why this is not working?
  And do you know what is the elegantly simple way to make it work?

I know the problem is in the " win.bind("<Return>",lambda
event,myself=win:myself.destroy)" line, but I don't know how to make it
right.


Help me for free !

Tnxs!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20020207/7224d9e2/attachment.html>


More information about the Python-list mailing list