get() attribute for Entry in Tkinter
Peter Otten
__peter__ at web.de
Wed Jun 29 17:35:08 EDT 2011
Robert Upton wrote:
> 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.
Please don't paraphrase Python's error messages. Cut-and-paste the traceback
instead. This should give something like
$ python tmp_tk.py
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
File "tmp_tk.py", line 6, in Test
strVal = widgetEntry.get()
AttributeError: 'NoneType' object has no attribute 'get'
So the value of widgetEntry is None. How could that be?
> widgetEntry = Entry(textFrame).pack(side = LEFT)
The pack() method returns None; if you need a reference to the Entry widget
you have to split that line
widgetEntry = Entry(textFrame)
widgetEntry.pack(side=LEFT)
More information about the Python-list
mailing list