Python 3 tkinter: How to use .after() on canvas graphics?

Viewed 9792

I am trying to animate a circle that moves over time but i do not know how to use .after() on Canvas to add a delay before the circle changes position each time. Does anyone know how to do this? Thanks.

my code (i have put a .sleep() where i would like the delay to be):

from tkinter import *
import time
root = Tk()

c = Canvas(root, width = 500, height = 500)
c.pack()

oval = c.create_oval(0, 0, 0, 0)
for x in range(2, 50, 5):
    time.sleep(0.1)
    c.delete(oval)
    oval = c.create_oval(x+50, x+50, x+50, x+50)
1 Answers
Related