Created
May 11, 2019 15:33
-
-
Save aambrioso1/d99b60fde0e90f4eb38224851869b6cc to your computer and use it in GitHub Desktop.
Animation demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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