blob: 5146e6fd953561ca5b8685a6c4ade3c5633f3dac [file] [log] [blame]
Guido van Rossum35820f71994-10-07 09:55:26 +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):
Tim Peters182b5ac2004-07-18 06:16:08 +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()