2 # the next line restarts using wish \
6 # This script generates a demo application containing only a "square"
7 # widget. It's only usable in the "tktest" application or if Tk has
8 # been compiled with tkSquare.c. This demo arranges the following
9 # bindings for the widget:
11 # Button-1 press/drag: moves square to mouse
12 # "a": toggle size animation on/off
14 # RCS: @(#) $Id: square,v 1.2 1998/09/14 18:23:30 stanton Exp $
17 pack .s
-expand yes -fill both
20 bind .s
<1> {center
%x
%y
}
21 bind .s
<B1-Motion
> {center
%x
%y
}
25 # The procedure below centers the square on a given position.
29 .s position
[expr $x-($a/2)] [expr $y-($a/2)]
32 # The procedures below provide a simple form of animation where
33 # the box changes size in a pulsing pattern: larger, smaller, larger,
51 if {$s >= 40} {set inc
-3}
52 if {$s <= 10} {set inc
3}
53 .s size
[expr {$s+$inc}]