from Tkinter import * def move(): global listcoordx,listcoordy,bal,listdx,listdy dx=int(listdx[bal]) listcoordx[bal]=int(listcoordx[bal]) if listcoordx[bal]>380 or listcoordx[bal]<20 : dx=-dx listdx[bal]=dx listcoordx[bal]=listcoordx[bal]+dx dy=int(listdy[bal]) listcoordy[bal]=int(listcoordy[bal]) if listcoordy[bal]>380 or listcoordy[bal]<20 : dy=-dy listdy[bal]=dy listcoordy[bal]=listcoordy[bal]+dy can.coords(listbal[bal],listcoordx[bal]-20,listcoordy[bal]-20,listcoordx[bal]+20,listcoordy[bal]+20) bal=bal+1 if bal==4: bal=0 if flag==1: fen.after(1,move) def go(): global flag,b if flag==0: flag=1 move() def stop(): global flag flag=0 def quit(): fen.destroy() fen=Tk() listbal=['b1','b2','b3','b4'] listcoordx=['50','300','50','300'] listcoordy=['50','50','300','300'] listdx=['5','5','5','5'] listdy=['5','5','5','5'] listcoul=['red','blue','green','yellow'] flag,bal=0,0 can=Canvas(fen,width=400,height=400,bg='dark grey') can.grid(row=1,column=1,rowspan=3) while bal