How to clear the Entry widget after a button is pressed in Tkinter?

后端 未结 11 1087
渐次进展
渐次进展 2020-12-01 10:44

I\'m trying to clear the Entry widget after the user presses a button using Tkinter.

I tried using ent.delete(0, END), but I got an error

11条回答
  •  萌比男神i
    2020-12-01 11:00

    I'm unclear about your question. From http://effbot.org/tkinterbook/entry.htm#patterns, it seems you just need to do an assignment after you called the delete. To add entry text to the widget, use the insert method. To replace the current text, you can call delete before you insert the new text.

    e = Entry(master)
    e.pack()
    
    e.delete(0, END)
    e.insert(0, "")
    

    Could you post a bit more code?

提交回复
热议问题