Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

canvas "moveto" .. is it a BUG ?

78 views
Skip to first unread message

aldo.w....@gmail.com

unread,
Aug 27, 2021, 6:21:42 PM8/27/21
to
I'm working on Windows10, TclTk 8.6.11 (64bit)

Working with a canvas, and trying to use the "moveto" command, I noticed this strange behavior that I would call it a BUG.

See the short example below; in practice when I move-to an item (a rectangle) to (x,y), its coords are changed to(x+1,y+1,.....) !

Is it a BUG or can you give some explanation ?

canvas .c ; pack .c
.c create rectangle 0 0 50 50 -tag RECT
.c coords RECT
# ---> 0.0 0.0 50.0 50.0 (ok)
.c move RECT 100 100
.c coords RECT
# --> 100.0 100.0 150.0 150.0 (ok)
### NOW moving with "moveto" ...
.c moveto RECT 100 100
.c coords RECT
# --> 101.0 101.0 151.0 151.0 (WRONG ! it should be 100 100 150 150)
.c moveto RECT 0 0
.c coords RECT
# --> 1.0 1.0 51.0 51.0 (WRONG ! it should be 0 0 50 50)

Uwe Schmitz

unread,
Aug 30, 2021, 4:44:58 AM8/30/21
to
Please try this:

> canvas .c ; pack .c
> .c create rectangle 0 0 50 50 -outline "" -tag RECT
> .c moveto RECT 100 100
> .c coords RECT
100.0 100.0 150.0 150.0

The problem is that the rectangle in your example gets an outline
per default which counts when calculating the bounding box:

pathName moveto tagOrId xPos yPos
Move the items given by tagOrId in the canvas coordinate space so that the first
coordinate pair (the upper-left corner of the bounding box) ...

Hope that helps.

aldo.w....@gmail.com

unread,
Sep 5, 2021, 4:47:27 PM9/5/21
to
Sorry but I don't agree.

From the canvas widget spec:
[..] pathName moveto tagOrId xPos yPos
Move the items given by tagOrId in the canvas coordinate space so that the first coordinate pair of the bottommost item with tag tagOrId is located at position (xPos,yPos). xPos and yPos may be the empty string, in which case the corresponding coordinate will be unchanged. All items matching tagOrId remain in the same positions relative to each other. This command returns an empty string.

With other words, "moveto" has nothing to do with the item's border thickness or the bbox, just with the position of item as returned by the "coords" method.
As my little code snippet demonstrated, when I "moveto" a RECT to (100,100) the "first coordinate pair of the bottommost item"
it's not moved to (100,100) but it's moved to (101,101) !

I think that I should open a BUG.

aldo.w....@gmail.com

unread,
Sep 5, 2021, 5:01:46 PM9/5/21
to

Uwe Schmitz

unread,
Sep 6, 2021, 5:22:40 AM9/6/21
to
> From the canvas widget spec:
> [..] pathName moveto tagOrId xPos yPos
> Move the items given by tagOrId in the canvas coordinate space so that the first coordinate pair of the bottommost item with tag tagOrId is located at position (xPos,yPos). xPos and yPos may be the empty string, in which case the corresponding coordinate will be unchanged. All items matching tagOrId remain in the same positions relative to each other. This command returns an empty string.
>
I don' know where you get this specification, which doesn't mention the
bounding box.
IMO the "official" documentation for canvas moveto (V8.6) is here:
https://www.tcl.tk/man/tcl8.6/TkCmd/canvas.html#M60

and this mentions the bounding box as the source for the moveto.

nemethi

unread,
Sep 6, 2021, 9:04:45 AM9/6/21
to
Am 06.09.21 um 11:22 schrieb Uwe Schmitz:
The clarification "(the upper-left corner of the bounding box)" was
added to the description of the moveto command in the canvas man page in
Tk 8.6.11, thus fixing a documentation bug reported by Schelte Bron back
in 2014. See

https://core.tcl-lang.org/tk/tktview?name=279b027fd7

--
Csaba Nemethi https://www.nemethi.de mailto:csaba....@t-online.de

aldo.w....@gmail.com

unread,
Sep 7, 2021, 11:56:01 AM9/7/21
to
Many thanks Csaba,
I wasn't able to find that old BUG among the Tk tickets.
Let me say that I'm not happy with that Fix (the spec was fixed instead of the implementation ..),.
Anyway, if these are the new specifications, I will be very careful in using the "moveto" command.
Thanks again
Aldo
0 new messages