home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / vrml / cp2b2x.exe / DATA.Z / hscale.tcl < prev    next >
Text File  |  1996-04-23  |  2KB  |  44 lines

  1. # hscale.tcl --
  2. #
  3. # This demonstration script shows an example with a horizontal scale.
  4. #
  5. # @(#) hscale.tcl 1.1 95/05/26 15:56:31
  6.  
  7. set w .hscale
  8. catch {destroy $w}
  9. toplevel $w
  10. wm title $w "Horizontal Scale Demonstration"
  11. wm iconname $w "hscale"
  12. positionWindow $w
  13.  
  14. 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."
  15. pack $w.msg -side top -padx .5c
  16.  
  17. frame $w.buttons
  18. pack  $w.buttons -side bottom -expand y -fill x -pady 2m
  19. button $w.buttons.dismiss -text Dismiss -command "destroy $w"
  20. button $w.buttons.code -text "See Code" -command "showCode $w"
  21. pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
  22.  
  23. frame $w.frame -borderwidth 10
  24. pack $w.frame -side top -fill x
  25.  
  26. canvas $w.frame.canvas -width 50 -height 50 -bd 0 -highlightthickness 0
  27. $w.frame.canvas create polygon 0 0 1 1 2 2 -fill DeepSkyBlue3 -tags poly
  28. $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line
  29. scale $w.frame.scale -orient horizontal -length 284 -from 0 -to 250 \
  30.     -command "setWidth $w.frame.canvas" -tickinterval 50
  31. pack $w.frame.canvas -side top -expand yes -anchor s -fill x  -padx 15
  32. pack $w.frame.scale -side bottom -expand yes -anchor n
  33. $w.frame.scale set 75
  34.  
  35. proc setWidth {w width} {
  36.     incr width 21
  37.     set x2 [expr $width - 30]
  38.     if {$x2 < 21} {
  39.     set x2 21
  40.     }
  41.     $w coords poly 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15
  42.     $w coords line 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15
  43. }
  44.