I'm currently working with Tkinter, trying to make a text widget that can update its value every second, but I don't know why it doesn't work as expected. I hard-coded the text widget position @@
self.text = tk.Text(self.root, height=25, width=97)
self.text.configure(state='disabled')
self.text.place(x = 10, y = 150)
def update_text(self):
self.text.delete('1.0', tk.END)
self.text.insert(tk.END, str(self.i))
self.i += 1
self.root.after(1000, self.update_text)
self.update_text()
self.root.mainloop()
Setting the text widget's state to 'normal' solved the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.