0

I am working with TKinter in Python 2.7, I cannot seem to get the value out of this entry object and I cannot figure out why.

def compute():
    a = float(side_one_entry.get())

side_one_entry = Entry(justify=CENTER).grid(row=1, column=2, columnspan=2)

go_button = Button(root, text="GO", command=compute).grid(row=10, columnspan=4)

I am crashing at the a = ... line. I have double checked that all rows columns line up correctly

Jack Frye
  • 583
  • 1
  • 7
  • 28
  • What is the error message? – jimscafe May 11 '16 at 01:16
  • 1
    The problem is when you ad .grid(..) to your Entrydeclaration, it does not return to side_one_entry the widget object but the return value of grid() - which is None. So side_one_entry = None Put the grid instruction on a new line side_one_entry.grid( ... ) – jimscafe May 11 '16 at 01:23
  • @jimscafe, you are right. thanks – Jack Frye May 11 '16 at 01:26
  • Could you be so kind as to tell us what tutorial or documentation is suggesting you do `Entry(...).grid(...)`. There must be hundreds of similar questions on this site. Maybe we can contact the authors of the documentation/tutorial to suggest a better way of programming. – Bryan Oakley May 11 '16 at 01:42
  • Mr. Oakley, I do wish experienced stack members would give beginners a little slack. I know this has been answered many times before, but beginners do not always know how to find those answers, how to ask the question in the best way. They soon learn and become valuable members of this community. Downgrading an answer within minutes of being asked can be demoralizing. Just a suggestion, I know you provide valuable answers on more complex questions. – jimscafe May 11 '16 at 03:05

0 Answers0