2009-01-04 14:53:28 -04:00
|
|
|
from tkinter import *
|
2004-07-18 03:16:08 -03:00
|
|
|
import string
|
1994-10-07 06:55:26 -03:00
|
|
|
|
|
|
|
# This program shows how to use a simple type-in box
|
|
|
|
|
|
|
|
class App(Frame):
|
|
|
|
def __init__(self, master=None):
|
2004-07-18 03:16:08 -03:00
|
|
|
Frame.__init__(self, master)
|
|
|
|
self.pack()
|
1994-10-07 06:55:26 -03:00
|
|
|
|
2004-07-18 03:16:08 -03:00
|
|
|
self.entrythingy = Entry()
|
|
|
|
self.entrythingy.pack()
|
1994-10-07 06:55:26 -03:00
|
|
|
|
2004-07-18 03:16:08 -03:00
|
|
|
# and here we get a callback when the user hits return. we could
|
|
|
|
# make the key that triggers the callback anything we wanted to.
|
|
|
|
# other typical options might be <Key-Tab> or <Key> (for anything)
|
|
|
|
self.entrythingy.bind('<Key-Return>', self.print_contents)
|
1994-10-07 06:55:26 -03:00
|
|
|
|
|
|
|
def print_contents(self, event):
|
2007-07-17 17:59:35 -03:00
|
|
|
print("hi. contents of entry is now ---->", self.entrythingy.get())
|
1994-10-07 06:55:26 -03:00
|
|
|
|
|
|
|
root = App()
|
|
|
|
root.master.title("Foo")
|
|
|
|
root.mainloop()
|