| EntryField |
UserPreferences |
| Tkinter Wiki | FrontPage | RecentChanges | TitleIndex | WordIndex | SiteNavigation | HelpContents | moin.sf.net |
The Tkinter ?StringVar class should be used to store the Entry widget's value
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | from Tkinter import *
root = Tk()
value = StringVar()
entry = Entry(root, textvariable=value)
entry.pack()
def get_value():
print value.get()
def set_value():
value.set("Hello World")
b = Button(root, text="Print Entry Value", command=get_value)
b.pack()
b = Button(root, text="Set Entry Value", command=set_value)
b.pack()
root.mainloop() |
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: