Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@CristhianBoujon
Created March 16, 2019 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CristhianBoujon/3010fe9966d2c6402f16747a67151144 to your computer and use it in GitHub Desktop.
Save CristhianBoujon/3010fe9966d2c6402f16747a67151144 to your computer and use it in GitHub Desktop.
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