You wouldn't need to use tags at all, if the column and row dimensions are fixed (or at least, a fixed proportion relative to the actual size of the canvas). Just grab the mouse coordinates on the button-down and button-up events, and quantize these wrt the cell width and height to determine which row and column holds the cell. Keep a separate 2-D data array to hold the current state of each cell, and as you update that array according to mouse actions, simply redraw the given rectangle with some suitable color to illustrate the change of state on that cell.
If you prefer to use images to illustrate the various states of cells (could get a bit noisy, visually, but you can be the judge of that), then presumably the set of states/images is fairly small, and copying a small rectangular image to a given x,y position is not that different from drawing a solid color rectangle at that position.
update: this made me think about "well, what are tags good for, then?" I think what they are good for are cases where the canvas may contain overlapping objects, and when someone clicks a position occupied by two or more objects, you get to see how many objects are involved, and which ones. But that doesn't seem to apply in your case, so you shouldn't bother with tags.
In reply to Re: Perl Tk Canvas and buckets of items
by graff
in thread Perl Tk Canvas and buckets of items
by herveus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |