This is not necessarily the current version of this TIP.
| TIP: | 236 |
| Title: | Absolute Positioning of Canvas Items |
| Version: | $Revision: 1.4 $ |
| Author: | Neil McKay <mckay at eecs dot umich dot edu> |
| State: | Draft |
| Type: | Project |
| Tcl-Version: | 8.5 |
| Vote: | Pending |
| Created: | Saturday, 25 December 2004 |
| Keywords: | Tk, anchor, place |
This TIP proposes adding a canvas widget command to set the absolute position of canvas items.
There are many situations where it is desirable to move a group of canvas items to a given position. Currently, this can be done by getting the items' bounding box, calculating the offset required to move the items to the desired position, and using the canvas move command to translate the items to where we want them. This is tedious and inefficient.
This TIP proposes adding a subcommand called place to the canvas widget command. It is analogous to the canvas move command, except that it accepts an absolute position instead of a relative displacement. It also allows the specification of an anchor point for the moved set of items. For instance, the command
.c place stuff 100 200
will displace all items tagged with stuff so that the center of their bounding box lies at the point (100,200). Likewise,
.c place stuff 100 200 -anchor sw
will do the same, except that it will place the lower left corner of the bounding box at (100,200).
The result of the command will be the empty string.
canvas place tagOrId x y ?-anchor anchor?
Argument description:
The canvas instance's command.
A specifier that selects one or more items. If no items are selected, the command does nothing.
The absolute coordinates of the target location. If either coordinate is given as an empty string, then that coordinate will remain unchanged.
Which corner of the bounding box of the item(s) is to be placed at the target location, in the usual format for anchors. Defaults to center.
A patch (against tcl8.5a2) that implements the place canvas subcommand is available [1].
This document is in the public domain.
This is not necessarily the current version of this TIP.