EntryField

The Tkinter StringVar class should be used to store the Entry widget's value

Example:

   1 from Tkinter import *
   2 
   3 root = Tk()
   4 value = StringVar()
   5 entry = Entry(root, textvariable=value)
   6 entry.pack()
   7 
   8 def get_value():
   9     print value.get()
  10 
  11 def set_value():
  12     value.set("Hello World")
  13 
  14 b = Button(root, text="Print Entry Value", command=get_value)
  15 b.pack()
  16 
  17 b = Button(root, text="Set Entry Value", command=set_value)
  18 b.pack()
  19 
  20 root.mainloop()
  21 

Please note a much more powerfull EntryField widget exists in the Pmw package, the Pmw.EntryField allows the user to define a validation function and it comes with an optional label.

Screenshot:

entry1.png

tkinter: EntryField (last edited 2010-07-26 11:59:12 by localhost)