Answers for "python tkinter clear text box"

2

python tkinter clear textbox

tex.delete('1.0', END)
Posted by: Guest on April-21-2021
1

python tkinter clear entry

# Clear an entry widget on button press
from tkinter import *

root = Tk()

def clearEntryInput():
    entry.delete(0, END)

entry = Entry(root, width=30) # You must .pack() or .grid() on the next line
entry.pack()

Button(root, text="Clear", command=clearEntryInput).pack()

root.mainloop()

# This is the error you get if you .pack() or .grid() on the same line:
# AttributeError: 'NoneType' object has no attribute 'delete'
# https://stackoverflow.com/questions/13002843/attributeerror-nonetype-object-has-no-attribute-delete
Posted by: Guest on May-02-2021

Python Answers by Framework

Browse Popular Code Answers by Language