tela tkinter não atualizando cor
Eu desenho um oval em uma tela que funciona perfeitamente também mostra a cor vermelha e os loops funcionam muito bem porque eu posso ver a impressão. Sua suposta mudar a cor sempre 1000ms. Mas não está mudando a cor?
def draw_light(self):
w = tk.Canvas(self.frame_Light)
w.pack()
w.create_oval(10, 10, 30, 30, fill="yellow", tags="light")
if self.light_on:
w.itemconfig("light", fill="blue")
self.light_on = False
print "on"
else:
w.itemconfig("light", fill="red")
self.light_on = True
print "of"
self.app.after(1000, self.draw_light)
ATUALIZAR mudou o código para suas sugestões ainda gera apenas a tela vermelha é isso
def draw_light(self):
self.ligth_canvas = tk.Canvas(self.frame_Light)
self.ligth_canvas.pack()
self.ligth_canvas.create_oval(10, 10, 30, 30, fill="yellow", tags="light")
self.app.after(0, self.change_light)
def change_light(self):
i = self.ligth_canvas.find_withtag("light")
if self.light_on:
self.ligth_canvas.itemconfig(i, fill="blue")
self.light_on = False
print "on"
else:
self.ligth_canvas.itemconfig(i, fill="red")
self.light_on = True
print "of"
self.app.after(5000, self.change_light)