Updated 2012-01-22 15:03:53 by dkf

Arjen Markus Drawing programs often have a scale on top and to the right to indicate the position of the cursor. I thought it would be nice to explore how to do that in Tcl. The script below is very rudimentary, but it shows the principle.
package require Tk
canvas .c -background white
pack   .c -fill both
bind   .c <Motion> {movePointer %x %y}

.c create line 10 10 10 20 -fill red  -width 3 -tags pointerx
.c create line 10 10 20 10 -fill blue -width 3 -tags pointery

proc movePointer {xcrd ycrd} {
    .c coords pointerx $xcrd 10    $xcrd 20
    .c coords pointery 10    $ycrd 20    $ycrd
}