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

  1. # vscale.tcl --
  2. #
  3. # This demonstration script shows an example with a vertical scale.
  4. #
  5. # @(#) vscale.tcl 1.1 95/05/26 15:56:41
  6.  
  7. set w .vscale
  8. catch {destroy $w}
  9. toplevel $w
  10. wm title $w "Vertical Scale Demonstration"
  11. wm iconname $w "vscale"
  12. positionWindow $w
  13.  
  14. label $w.msg -font $font -wraplength 3.5i -justify left -text "An arrow and a vertical scale are displayed below.  If you click or drag mouse button 1 in the scale, you can change the size 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
  25.  
  26. scale $w.frame.scale -orient vertical -length 284 -from 0 -to 250 \
  27.     -command "setHeight $w.frame.canvas" -tickinterval 50
  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 SeaGreen3 -tags poly
  30. $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line
  31. frame $w.frame.right -borderwidth 15
  32. pack $w.frame.scale -side left -anchor ne
  33. pack $w.frame.canvas -side left -anchor nw -fill y
  34. $w.frame.scale set 75
  35.  
  36. proc setHeight {w height} {
  37.     incr height 21
  38.     set y2 [expr $height - 30]
  39.     if {$y2 < 21} {
  40.     set y2 21
  41.     }
  42.     $w coords poly 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20
  43.     $w coords line 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20
  44. }
  45.