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?
Asked
Active
Viewed 74 times
0

DeeDeeAich
- 502
- 1
- 4
- 9
1 Answers
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
-
1Thanks, I completely forgot about this in tkinter. Lol – DeeDeeAich Oct 27 '20 at 15:16
-
@DeeDeeAich Would appreciate marking as answer. – Delrius Euphoria Oct 27 '20 at 15:16
-
1Sorry. Couldn’t do it yesterday and forgot lol. – DeeDeeAich Oct 28 '20 at 19:51