TIP: | 236 |
Title: | Absolute Positioning of Canvas Items |
Version: | $Revision: 1.10 $ |
Author: | Neil McKay <mckay at eecs dot umich dot edu> |
State: | Final |
Type: | Project |
Tcl-Version: | 8.6 |
Vote: | Done |
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 is done by getting the items' first coordinate, 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 moveto 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. For instance, the command
.c moveto stuff 100 200
will displace all items tagged with stuff so that the first coordinate of the first (bottom-most) tagged item lies at the point (100,200).
The result of the command will be the empty string.
canvas moveto tagOrId x y
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.
A patch (against tcl8.5a3) that implements the moveto canvas subcommand is available [1].
This document is in the public domain.
[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]
TIP AutoGenerator - written by Donal K. Fellows