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

后端 未结 11 1104
渐次进展
渐次进展 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条回答
  •  囚心锁ツ
    2020-12-01 10:47

    Simply define a function and set the value of your Combobox to empty/null or whatever you want. Try the following.

    def Reset():
        cmb.set("")
    

    here, cmb is a variable in which you have assigned the Combobox. Now call that function in a button such as,

    btn2 = ttk.Button(root, text="Reset",command=Reset)
    

提交回复
热议问题