Skip to content

Instantly share code, notes, and snippets.

@aambrioso1
Created May 11, 2019 15:33
Show Gist options
  • Save aambrioso1/d99b60fde0e90f4eb38224851869b6cc to your computer and use it in GitHub Desktop.
Save aambrioso1/d99b60fde0e90f4eb38224851869b6cc to your computer and use it in GitHub Desktop.
Animation demo
from tkinter import *
import time
gui = Tk()
gui.title('Animation Test')
gui.geometry('400x400')
c = Canvas(gui ,width=400 ,height=400)
c.pack()
oval = c.create_oval(5,5,60,60,fill='pink')
xd = 5
yd = 10
while True:
c.move(oval,xd,yd)
p=c.coords(oval)
if p[3] >= 400 or p[1] <=0:
yd = -yd
if p[2] >=400 or p[0] <=0:
xd = -xd
gui.update()
time.sleep(0.025)
gui.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment