[Tkinter-discuss] Pressing buttons
bob at greschke.com
Wed Apr 4 04:49:17 CEST 2007
You want to do something like this:
from Tkinter import *
Root = Tk()
EntryVar = StringVar()
def doSomething(e = None):
Sub = Frame(Root)
Ent = Entry(Sub, width = 10, variable = EntryVar)
Ent.pack(side = LEFT)
Ent.bind("<KP_Enter>", doSomething) <- for the numeric keypad Enter key
Button(Sub, text = "OK", command = doSomething).pack(side = LEFT)
Sub.pack(side = TOP)
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. :)
----- Original Message -----
From: "Ekaitz Lizundia" <elizundia at fitbak.com>
To: <tkinter-discuss at python.org>
Sent: Tuesday, April 03, 2007 04:51
Subject: [Tkinter-discuss] Pressing buttons
> how can i do the following it ? I have an Entry and a button "ok". I
> need that with the keyboard put a number and press enter.
> i put 456
> press enter
> The program must call a function, and later, the position of mouse is in
> entry again.
> Sorry, my english is very bad.
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
More information about the Tkinter-discuss