Reputation: 113
I am trying to update a Text
widget, but it's not updated no matter what I try, there is no error as well
def update():# a button calls this
textBox.delete(1.0, tk.END)
textBox.insert(tk.END,"test")
textBox = tk.Text(frame1,height=2,width=10)
textBox.config(state='disabled') #disable editing
textBox.grid(row=0,column=1,pady=2)
Upvotes: 1
Views: 887
Reputation: 7680
Using @JacksonPro's suggestion
import tkinter as tk
def update():# a button calls this
textBox.config(state="normal") # Make the state normal
textBox.delete("0.0", "end")
textBox.insert("end", "test")
textBox.config(state="disabled") # Make the state disabled again
root = tk.Tk()
textBox = tk.Text(root, height=2, width=10)
textBox.config(state="disabled") #disable editing
textBox.grid(row=0, column=1, pady=2)
button = tk.Button(root, text="Click me", command=update)
button.grid(row=1, column=1)
root.mainloop()
Upvotes: 3