canvas.find_...methods

andrea valle andrea.valle at unito.it
Fri Oct 22 04:49:32 EDT 2004


Hi to all,
I'm tweaking with canvases and items.
Everything's ok with .find_closest, but I cannot understand why the 
output of find_overlapping and find_enclosed is always ().
Here's my piece of code:

from Tkinter import *
from random import *

# The binding func

def coord(event):
	print event.x, event.y
	print c.find_closest(event.x, event.y) # ok
	print c.find_overlapping(0, 200,0, 200) #catch everything: always ()
	print c.find_enclosed(0, 200,0, 200) #catch everything: always ()
	print "\n"



root = Tk()
c = Canvas(root, width = 200, height = 200, background = "yellow")
c.bind('<Button-1>', coord)
ar = []
for x in range(10):
	ov = c.create_oval(0, 0, 10, 10, outline = "blue")
	ar.append(ov)

# random positioning of canvas.items
for x in ar:
	a = randint (0, 200)
	b = randint (0, 200)
	c.coords(x, a, b, a+10, b+10)
c.pack()
root.mainloop()
		

I think I'm missing somenthing. Any suggestion?
Thanks a lot

-a-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1097 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041022/c442350b/attachment.bin>


More information about the Python-list mailing list