-1

I am trying to bind a function to my EntryBox.

nameEntry = tk.Entry(root,textvariable=nameInput,bg="white",font=("Arial",28)).grid(row=2,column=2)
nameEntry.bind("<FocusOut>",nameValidation(nameInput.get()))

However I get this error

AttributeError: 'NoneType' object has no attribute 'bind'

The result of type(nameEntry)

<class 'NoneType'>

When I remove the .bind line, the tkinter GUI loads perfectly. I am confused as to why nameEntry is being treated as 'NoneType'.

Lyra Orwell
  • 1,048
  • 4
  • 17
  • 46
  • 1
    Does this answer your question? [Tkinter: AttributeError: NoneType object has no attribute ](https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-attribute-name) – Saad Jun 27 '20 at 14:20

1 Answers1

2

the grid() methods returns None... that's the whole issue. So, split the first line into two line so:

nameEntry = tk.Entry(root,textvariable=nameInput,bg="white",font=("Arial",28))
nameEntry.grid(row=2,column=2)
Anwarvic
  • 12,156
  • 4
  • 49
  • 69