[Tkinter-discuss] How to Reference many Canvas Ovals

Ken Borgmeyer ken at borgmeyer.com
Fri May 5 00:04:16 CEST 2006

YAHOO! It makes sense and works GREAT! Thank you Pavel! This will make
the greatest robot EVER! hehe

-----Original Message-----
From: Pavel Kosina
Sent: Thursday, May 04, 2006 10:41 AM
To: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] How to Reference many Canvas Ovals

Hi, electron

> EHLO! Anyone have code showing how to reference many individual Canvas
> objects? 

put them into list

> for i in range(1,number+1)
> n[i] = canvas.create_oval()

instead of this, there should be something like
for i in range(1000):
	x,y=random.randint(0,X), random.randint(0,Y)
	o=canvas.create_oval((x,y,x+10,y+10), fill='red')

> and
> if variable[i] == "blue" then canvas.n[i].config(fill='blue')

no, again, if you want to change color of 578th :-) oval, do it this

canvas.itemconfig(all[578-1], fill='pink')

Pavel Kosina

More information about the Tkinter-discuss mailing list