from Tkinter import *
from tkMessageBox import *
class EntryDemo( Frame ):
def __init__( self ):
Frame.__init__( self )
self.pack( expand = YES, fill = BOTH )
self.master.title( "Testing Entry Components" )
self.master.geometry( "325x100" )
self.frame1 = Frame( self )
self.frame1.pack( pady = 5 )
self.text2 = Entry( self.frame1, name = "text2" )
self.text2.insert( INSERT, "Enter text here" )
self.text2.bind( "", self.showContents )
self.text2.pack( side = LEFT, padx = 5 )
def showContents( self, event ):
theName = event.widget.winfo_name()
theContents = event.widget.get()
showinfo( "Message", theName + ": " + theContents )
EntryDemo().mainloop()