You haven't shown any code and you are throwing around terms like "pack with grid" for canvas items. I'm not sure you understand...... the canvas widget itself can be packed or gridded, but items on the canvas cannot.....they are placed somewhere on the canvas. Unless you are talking about a grid item (read perldoc Tk::Canvas and search for createGrid). So you can't use packForget,etc, except on the canvas widget itself.
As far as finding positions of items, each item type will have it's own quirks. Some items, you can get the "coords" or "x" ,"y". But you need to know how many points are there, like in polygons.
Sometimes you need to use the bbox. The bbox is useful for finding a bounding box of a group of similarly tagged items. Bbox is also useful for text (to account for font size).my @coords = $canvas->coords($id); my ( $x0, $y0, $x1, $y1 ) = $canvas->coords($id);
It is not too hard to setup a hash, and store your positions exactly if that is easier for you. In Tk::Zinc( a suped-up canvas), positions can be kept with tget and tset (transformation matrix), see Newtons-Cradle-Tk-Zinc. In that case, it was difficult to get the balls to return to their starting rest position without a jitter effect.
In reply to Re^5: Fogetting Tk Canvas widgets
by zentara
in thread Fogetting Tk Canvas widgets
by merrymonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |