Answer the question
In order to leave comments, you need to log in
How to clear text input field in tkinter?
I need to clear a text input field in tkinter. I found this solution on the Internet: entry.delete(0, END)
Where entry is the name of the input field (direct link to it), 0 is the beginning of the input field string, END is the end of the input field string. This command should clear the input field from start to finish. But this error pops up:
AttributeError: 'NoneType' object has no attribute 'delete'
Who is familiar with tkinter, please help.
Answer the question
In order to leave comments, you need to log in
The method place
does not return anything, so the line of code
assigns a entry
value to a variable None
Correct to
entry = Entry(canvas, width=20,)
entry.place(x=150, y=300)
First you need to get the field itself. You didn't receive it.
within the class:
class Application(Tk):
def OnEnterInput(self, event):
text=u''+self.input.get()
self.Send(text)
self.input.delete(0, END)
def createWidgets(self):
.....
self.input = Entry(self, textvariable=self.inline)
self.input.grid(row=0, column=0, columnspan=2, pady=3, padx=3, sticky='ew')
self.input.bind("<Return>", self.OnEnterInput)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question