Question

I am a GUI that uses an entry field, I want the delete button to delete the end character held in the index within the entry field. I have managed to get my clear button working, by doing the following

entry.delete(0, END) #Deletes all values in the entry field

I thought I could just do the following to delete the end item but it does not work. Any ideas

entry.delete(END)

I replace 'END' above with a number it will delete that number, but I'm sure there must be a quicker way.

Was it helpful?

Solution

You can calculate the length of the text and use it as the start of the range:

start = len(entry.get()) - 1
entry.delete(start, END)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top