OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / library / demos / hscale.tcl
1 # hscale.tcl --
2 #
3 # This demonstration script shows an example with a horizontal scale.
4
5 if {![info exists widgetDemo]} {
6     error "This script should be run from the \"widget\" demo."
7 }
8
9 package require Tk
10
11 set w .hscale
12 catch {destroy $w}
13 toplevel $w
14 wm title $w "Horizontal Scale Demonstration"
15 wm iconname $w "hscale"
16 positionWindow $w
17
18 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."
19 pack $w.msg -side top -padx .5c
20
21 ## See Code / Dismiss buttons
22 set btns [addSeeDismiss $w.buttons $w]
23 pack $btns -side bottom -fill x
24
25 frame $w.frame -borderwidth 10
26 pack $w.frame -side top -fill x
27
28 canvas $w.frame.canvas -width 50 -height 50 -bd 0 -highlightthickness 0
29 $w.frame.canvas create polygon 0 0 1 1 2 2 -fill DeepSkyBlue3 -tags poly
30 $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line
31 scale $w.frame.scale -orient horizontal -length 284 -from 0 -to 250 \
32         -command "setWidth $w.frame.canvas" -tickinterval 50
33 pack $w.frame.canvas -side top -expand yes -anchor s -fill x  -padx 15
34 pack $w.frame.scale -side bottom -expand yes -anchor n
35 $w.frame.scale set 75
36
37 proc setWidth {w width} {
38     incr width 21
39     set x2 [expr {$width - 30}]
40     if {$x2 < 21} {
41         set x2 21
42     }
43     $w coords poly 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15
44     $w coords line 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15
45 }