I want to update the color of a circle in Tkinter in python 2. I can make my circle but the color does not update in my task() method until I stop running the program. How can I make the color update as soon as val is greater than 4?
from Tkinter import *
m = Tk()
w = Canvas(m, width = 100, height = 100)
w.pack()
cir = w.create_oval(50, 50, 100, 100)
def task():
while True:
val += 1
if val > 4:
w.itemconfig(cir, fill = "blue")
m.after(2000, task)
m.mainloop()
while True:with nobreak. What did you expect?while True:with nobreak. Again, what did you expect?valas fast as it can, basically freezing your program unless you go into multiprocessing/threading. What you're trying to ask is how to refresh the display between eachwhile Truecycle.