Oops. Yup. I fixed when I cut an pasted from the email and tried
and run it, but forgot to go back and change the email. The spelling
checker should check for things like that. :) It should be
"textvariable = EntryVar" in the Entry() line.
Bob
On Apr 3, 2007, at 21:26, John McMonagle wrote:
> Not sure where Bob pulled "variable" out of, but rest assured it's not
> an option to the Entry widget.
> Bob Greschke wrote:
>> You want to do something like this:
>>
>> from Tkinter import *
>> Root = Tk()
>>
>> EntryVar = StringVar()
>>
>> def doSomething(e = None):
>> print EntryVar.get()
>> return
>>
>> Sub = Frame(Root)
>> Ent = Entry(Sub, width = 10, variable = EntryVar)
>> Ent.pack(side = LEFT)
>> Ent.bind("<Return>", doSomething)
>> Ent.bind("<KP_Enter>", doSomething) <- for the numeric keypad
>> Enter key
>> Button(Sub, text = "OK", command = doSomething).pack(side = LEFT)
>> Sub.pack(side = TOP)
>>
>> Root.mainloop()
>>
>>
>> It is important that the Entry field .pack() be on a line by
>> itself and not
>> combined like Entry().pack(), otherwise Ent will be equal to None
>> and the
>> bind will not work.
>>
>> No problem with the English. We'll get through it. :)
>>
>> Bob
>>
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss