get() attribute for Entry in Tkinter
Robert Upton
yybar85712 at gmail.com
Wed Jun 29 15:15:02 EDT 2011
Dear Pythoners,
I am in the process of generating a simple GUI that wants to read a
string and print it to the terminal after engaging a button. I am
running into a problem where Python says it does not understand the
get() attribute for Entry. My code is very simple and is shown
below. Please provide comments.
Thankyou
import Tkinter
from Tkinter import *
def Test():
global widgetEntry
strVal = widgetEntry.get()
print str(strVal)
root = Tk() # opens a
new window
textFrame = Frame(root)
widgetLabel = Label(textFrame)
widgetLabel.config(text = 'Enter text')
widgetLabel.pack(side = LEFT)
widgetLabel.pack(expand = YES, fill = BOTH)
widgetEntry = Entry(textFrame).pack(side = LEFT)
textFrame.pack()
Button(root, text = 'Submit', command=Test).pack(side=LEFT)
root.mainloop()
More information about the Python-list
mailing list