Automatically change values of on a canvas tkinter every second
Solution 1:
The ID of the text object is returned by create_text
. Save it and use it to change the text with canvas.itemconfig
:
def update_temp():
c, _ = read_temp()
canvas.itemconfig(temp_text_id, text=str(c))
canvas.after(1000, update_time)
c, f = read_temp()
temp_text_id = canvas.create_text(
1068.0,
744.0,
anchor="nw",
text=str(c),
fill="#FFFFFF",
font=("Poppins Bold", 120 * -1)
)
canvas.after(1000, update_temp)
window.mainloop()