blob: 1f55df51db4c0877af44d8ab09cc6e19581e203f [file] [log] [blame]
Benjamin Petersond6d63f52009-01-04 18:53:28 +00001from tkinter import *
Tim Peters182b5ac2004-07-18 06:16:08 +00002import string
Guido van Rossum35820f71994-10-07 09:55:26 +00003
4# This program shows how to use a simple type-in box
5
6class App(Frame):
7 def __init__(self, master=None):
Tim Peters182b5ac2004-07-18 06:16:08 +00008 Frame.__init__(self, master)
9 self.pack()
Guido van Rossum35820f71994-10-07 09:55:26 +000010
Tim Peters182b5ac2004-07-18 06:16:08 +000011 self.entrythingy = Entry()
12 self.entrythingy.pack()
Guido van Rossum35820f71994-10-07 09:55:26 +000013
Tim Peters182b5ac2004-07-18 06:16:08 +000014 # and here we get a callback when the user hits return. we could
15 # make the key that triggers the callback anything we wanted to.
16 # other typical options might be <Key-Tab> or <Key> (for anything)
17 self.entrythingy.bind('<Key-Return>', self.print_contents)
Guido van Rossum35820f71994-10-07 09:55:26 +000018
19 def print_contents(self, event):
Collin Winter6f2df4d2007-07-17 20:59:35 +000020 print("hi. contents of entry is now ---->", self.entrythingy.get())
Guido van Rossum35820f71994-10-07 09:55:26 +000021
22root = App()
23root.master.title("Foo")
24root.mainloop()