Skip to content
Advertisement

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

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 saying that strings don’t have the attribute delete.

Here is my code, where I’m getting error on real.delete(0, END):

JavaScript

Advertisement

Answer

After poking around a bit through the Introduction to Tkinter, I came up with the code below, which doesn’t do anything except display a text field and clear it when the "Clear text" button is pushed:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement