PageRenderTime 263ms CodeModel.GetById 141ms app.highlight 2ms RepoModel.GetById 119ms app.codeStats 0ms

/Demo/tkinter/matt/entry-simple.py

http://unladen-swallow.googlecode.com/
Python | 24 lines | 14 code | 6 blank | 4 comment | 0 complexity | 11c16e8b520ce40094d5d5c96424c34a MD5 | raw file
 1from Tkinter import *
 2import string
 3
 4# This program  shows how to use a simple type-in box
 5
 6class App(Frame):
 7    def __init__(self, master=None):
 8        Frame.__init__(self, master)
 9        self.pack()
10
11        self.entrythingy = Entry()
12        self.entrythingy.pack()
13
14        # 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)
18
19    def print_contents(self, event):
20        print "hi. contents of entry is now ---->", self.entrythingy.get()
21
22root = App()
23root.master.title("Foo")
24root.mainloop()