Text with pre-set value : Text « Tkinker « Python Tutorial






Text with pre-set value
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( "<Return>", 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()








18.30.Text
18.30.1.Set text backgroundSet text background
18.30.2.A simple text or file viewer componentA simple text or file viewer component
18.30.3.Disabled Text controlDisabled Text control
18.30.4.Turn Text control to a password input fieldTurn Text control to a password input field
18.30.5.Text with pre-set valueText with pre-set value