[Tkinter-discuss] animation

prasad rao prasadaraon50 at gmail.com
Sat Jan 2 12:41:30 CET 2010


Hi!
 Last month I got code to animate using sequence of images from this list.
I am trying to move bubbles across a canvas.
I am unable to do multiple bubbles.
=code=
def pp2():
	def  cc():
		a=[x  for  x in range(0,500,10)]
		b=[x  for  x in range(500,0,-10)]
		c=[x  for  x in range(0,500,10)]
		random.shuffle(c)
		d=lambda : random.choice([a,b,c,a,b])
		return d()
	z=lambda : random.randint(1,500)
	k=z()
	q=cc()
	def anim(cv):
	
	 def view():
		 x1=q[cv]
		 x2=x1+10
		 y1=k
		 y2=y1+10
		
		 win.create_oval(x1,y1,x2,y2,tag='ani')
	 win.delete('ani')
	 try:
		 view()
	 except IndexError:
		 cv=0
		 view()

	 win.update_idletasks()
	 cv=cv+1
	 root.after(50,anim,cv)
	root=Tk();win=Canvas(root,width=600,height=400);win.pack()
	root.after(10,anim, 0);root.mainloop()
=code=
please someone tell me how to make multiple bubbles move  randomly
across canvas on  different x axis and y axises(not  flashing).
I sped lots of time  in vain.

Wish you happy New year.
prasad


More information about the Tkinter-discuss mailing list