Upgrade to Tcl/Tk 8.5b2
[msysgit.git] / mingw / lib / tk8.5 / demos / hscale.tcl
blob1498902219a3038b3781b93c42bfd01ebd7cbc9a
1 # hscale.tcl --
3 # This demonstration script shows an example with a horizontal scale.
5 # RCS: @(#) $Id: hscale.tcl,v 1.5 2004/12/21 11:56:35 dkf Exp $
7 if {![info exists widgetDemo]} {
8 error "This script should be run from the \"widget\" demo."
11 package require Tk
13 set w .hscale
14 catch {destroy $w}
15 toplevel $w
16 wm title $w "Horizontal Scale Demonstration"
17 wm iconname $w "hscale"
18 positionWindow $w
20 label $w.msg -font $font -wraplength 3.5i -justify left -text "An arrow and a horizontal scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the length of the arrow."
21 pack $w.msg -side top -padx .5c
23 ## See Code / Dismiss buttons
24 set btns [addSeeDismiss $w.buttons $w]
25 pack $btns -side bottom -fill x
27 frame $w.frame -borderwidth 10
28 pack $w.frame -side top -fill x
30 canvas $w.frame.canvas -width 50 -height 50 -bd 0 -highlightthickness 0
31 $w.frame.canvas create polygon 0 0 1 1 2 2 -fill DeepSkyBlue3 -tags poly
32 $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line
33 scale $w.frame.scale -orient horizontal -length 284 -from 0 -to 250 \
34 -command "setWidth $w.frame.canvas" -tickinterval 50
35 pack $w.frame.canvas -side top -expand yes -anchor s -fill x -padx 15
36 pack $w.frame.scale -side bottom -expand yes -anchor n
37 $w.frame.scale set 75
39 proc setWidth {w width} {
40 incr width 21
41 set x2 [expr {$width - 30}]
42 if {$x2 < 21} {
43 set x2 21
45 $w coords poly 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15
46 $w coords line 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15