On Tue, 2006-04-04 at 14:47 -0700, fxe wrote: > Hi, > I am using tkinter and I have a canvas that with several rectangles drawn > on it. The rectangles need to have bindings to move and resize them. No > problem here, but I also need to display a grid on the same canvas, for > which I am using create_line. My problem is I do not want the grid lines to > be able to move and resize . > > Is this doable or any suggestions on an alternative.Maybe another way to > display my grid on top of the canvas? >
When you create your canvas items use the tags option to differentiate items you wish to group together. For example, canvas.create_line(x1,y1,x2,y2,fill='#000000',tags='grid') canvas.create_rectangle(x1,y1,x2,y2,fill='#FF0000',outline='#FF0000',tags='rect') You can ensure that the grid lines are always displayed below the rectangles by using the tag_lower method: canvas.tag_lower('grid', 'rect') You can bind events to the named tags rather than the canvas as a whole: canvas.tag_bind('rect', '<Button-1>', startMove) canvas.tag_bind('rect', '<Button1-Motion>', moveRect) canvas.tag_bind('rect', '<Button1-ButtonRelease>', finishMove) Now when you click on a canvas item with a 'grid' tag nothing will happen, but if you click on a canvas item with a 'rect' tag you will invoke the appropriate function. HTH, John McMonagle -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- http://mail.python.org/mailman/listinfo/python-list