How to clear/delete the contents of a Tkinter Text widget?

后端 未结 7 1340
谎友^
谎友^ 2020-12-09 01:05

I am writing a Python program in TKinter on Ubuntu to import and print the name of files from particular folder in Text widget. It is just adding f

7条回答
  •  执念已碎
    2020-12-09 01:47

    for me "1.0" didn't work, but '0' worked. This is Python 2.7.12, just FYI. Also depends on how you import the module. Here's how:

    import Tkinter as tk
    window = tk.Tk()
    textBox = tk.Entry(window)
    textBox.pack()
    

    And the following code is called when you need to clear it. In my case there was a button Save that saves the data from the Entry text box and after the button is clicked, the text box is cleared

    textBox.delete('0',tk.END)
    

提交回复
热议问题