Created
March 16, 2019 11:26
-
-
Save CristhianBoujon/3010fe9966d2c6402f16747a67151144 to your computer and use it in GitHub Desktop.
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
import tkinter as tk | |
import time | |
class Particula: | |
def __init__(self, x, y, radio, color='blue'): | |
self.circulo = canvas.create_oval( | |
x - radio, y - radio, x + radio, y + radio, fill=color | |
) | |
def mover(self): | |
canvas.move(self.circulo, 1, 0) | |
if __name__ == '__main__': | |
root = tk.Tk() | |
# create canvas | |
canvas = tk.Canvas(root) | |
canvas.pack() | |
# create objects | |
p = Particula(50, 50, 20) | |
p2 = Particula(100, 100, 5, 'red') | |
while True: | |
time.sleep(0.025) | |
p.mover() | |
p2.mover() | |
canvas.update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment