gorskaja2019

Untitled

Apr 24th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. from tkinter import*
  2. from random import *
  3. from time import *
  4.  
  5. class Ball:
  6. def __init__(self, canvas, color):
  7. self.canvas = canvas
  8. self.id = canvas.create_oval(10,10,25,25,fill=color)
  9. self.canvas.move(self.id, 225, 180)
  10. def draw(self):
  11. self.canvas.move(self.id, 1, 0)
  12.  
  13. root = Tk()
  14. root.title('Пинг-понг')
  15. canvas = Canvas(width = 500, height = 400, bg = 'deepskyblue')
  16. canvas.pack()
  17.  
  18. ball = Ball(canvas, 'red')
  19.  
  20. while True:
  21. ball.draw()
  22. root.update_idletasks()
  23. root.update()
  24. sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment