0

Whenever I try to do ttk.Entry.delete(0, END) on the Entry() object, it gives me an AttributeError. The Entry widget is showing up as None. How do I fix this?

DeeDeeAich
  • 502
  • 1
  • 4
  • 9

1 Answers1

0

Here is a proper example on how it should be:

a = ttk.Entry(root)
a.pack()

This is because in python when saying x = a().b(), x will have the value returned by b(), so in this case pack() returns None, hence you are having x as None and when you say x.delete(0,END) you are literally saying None.delete(0,END) which gives you the error your getting.

Also as a sidenote, saying ttk.Entry.delete(0,END) will give you different error as it should be ttk.Entry().delete(0,END), which wont produce any error.

So always keep in mind to declare in one line and put in on the screen in another line.

Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46