Created
March 7, 2017 11:43
-
-
Save stahnni/15646ab225ffff2571228566ae9174fe to your computer and use it in GitHub Desktop.
using tkinter
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
""" | |
Make a triangle move across the screen to the right, | |
then down, then back to the left, and then back to its starting | |
position. Using tkinter | |
""" | |
import time | |
from tkinter import * | |
tk = Tk() | |
canvas = Canvas(tk, width=400, height=400) | |
canvas.pack() | |
#canvas.create_polygon(10,10, 50,110, 90,10) | |
canvas.create_polygon(10,10, 10,60, 50,35) | |
for x in range(0, 60): | |
canvas.move(1, 5, 0) | |
tk.update() | |
time.sleep(0.05) | |
for x in range(0,60): | |
canvas.move(1, 0, 5) | |
tk.update() | |
time.sleep(0.05) | |
for x in range(0,60): | |
canvas.move(1, -5, 0) | |
tk.update() | |
time.sleep(0.05) | |
for x in range(0,60): | |
canvas.move(1, 0, -5) | |
tk.update() | |
time.sleep(0.05) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment