from tkinter import*
import random
tk=Tk()
cnv=Canvas(tk, width=500, height=400)
cnv.pack()
class Ball:
def __init__(self,cnv,x,y,color):
self.cnv=cnv
self.id=cnv.create_oval(x,y,x+20,y+20,fill=color)
self.dy=2
# ball1=Ball(cnv,10,10,"red")
# ball2=Ball(cnv,10,10,"red")
list_ball=[]
colors=["red","orange","yellow","green","blue"]
for i in range(10):
x=random.randint(10,400)
y=random.randint(10,350)
list_ball.append(Ball(cnv,x,y,colors[i%5]))
import random
tk=Tk()
cnv=Canvas(tk, width=500, height=400)
cnv.pack()
class Ball:
def __init__(self,cnv,x,y,color):
self.cnv=cnv
self.id=cnv.create_oval(x,y,x+20,y+20,fill=color)
self.dy=2
# ball1=Ball(cnv,10,10,"red")
# ball2=Ball(cnv,10,10,"red")
list_ball=[]
colors=["red","orange","yellow","green","blue"]
for i in range(10):
x=random.randint(10,400)
y=random.randint(10,350)
list_ball.append(Ball(cnv,x,y,colors[i%5]))
Комментариев нет:
Отправить комментарий