Tkinter Text Widget은 응용 프로그램에 텍스트 작성기를 추가하는 데 사용됩니다. 여기에는 텍스트 편집기의 기능을 확장하는 데 사용되는 많은 속성과 속성이 있습니다. 입력 내용을 삭제하려면 delete("start", "end")를 사용할 수 있습니다. 방법.
예시
#Import the tkinter library
from tkinter import *
#Create an instance of tkinter frame
win = Tk()
#Set the geometry
win.geometry("600x250")
#Define a function to clear the input text
def clearToTextInput():
my_text.delete("1.0","end")
#Create a text widget
my_text=Text(win, height=10)
my_text.pack()
#Create a Button
btn=Button(win,height=1,width=10, text="Clear",command=clearToTextInput)
btn.pack()
#Display the window without pressing key
win.mainloop() 출력
위의 코드를 실행하면 입력 텍스트를 지우는 데 사용할 수 있는 텍스트 위젯과 버튼이 생성됩니다.

이제 "지우기" 버튼을 클릭하면 입력된 텍스트가 지워집니다.