| 
									
										
										
										
											1994-10-07 09:55:26 +00:00
										 |  |  | from Tkinter import * | 
					
						
							| 
									
										
										
										
											2004-07-18 06:16:08 +00:00
										 |  |  | import string | 
					
						
							| 
									
										
										
										
											1994-10-07 09:55:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # This program  shows how to use a simple type-in box | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class App(Frame): | 
					
						
							|  |  |  |     def __init__(self, master=None): | 
					
						
							| 
									
										
										
										
											2004-07-18 06:16:08 +00:00
										 |  |  |         Frame.__init__(self, master) | 
					
						
							|  |  |  |         self.pack() | 
					
						
							| 
									
										
										
										
											1994-10-07 09:55:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-18 06:16:08 +00:00
										 |  |  |         self.entrythingy = Entry() | 
					
						
							|  |  |  |         self.entrythingy.pack() | 
					
						
							| 
									
										
										
										
											1994-10-07 09:55:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-18 06:16:08 +00: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 09:55:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def print_contents(self, event): | 
					
						
							| 
									
										
										
										
											2007-07-17 20:59:35 +00:00
										 |  |  |         print("hi. contents of entry is now ---->", self.entrythingy.get()) | 
					
						
							| 
									
										
										
										
											1994-10-07 09:55:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | root = App() | 
					
						
							|  |  |  | root.master.title("Foo") | 
					
						
							|  |  |  | root.mainloop() |