I am having trouble using the delete method for Entry in tkinter. Currently I import tkinter as follows:
import Tkinter as tk
I then declare two variables that are used to track the value of two entry fields as follows:
self.UN = tk.StringVar()
self.PW = tk.StringVar()
I am able to get the value using
self.UN.get()
without any issue but when try to delete the value using
self.UN.delete(0, END)
I get the error, StringVar instance has no attribute 'delete' I have looked through other possible solutions on SO but none seem relevant to my issue. I used the following tutorial to try and get this to work: http://effbot.org/tkinterbook/entry.htm
I have also tried variations on the delete like putting Tk.END inside the brackets, but can't get this going. Any help is appreciated.
Instead of delete()
, you have to use set()
:
field_name.set('')
It's working from my side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With