"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/tltcl/lib/tk8.6/demos/vscale.tcl" (17 Mar 2020, 1477 Bytes) of package /windows/misc/install-tl.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Tcl/Tk source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # vscale.tcl --
    2 #
    3 # This demonstration script shows an example with a vertical 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 .vscale
   12 catch {destroy $w}
   13 toplevel $w
   14 wm title $w "Vertical Scale Demonstration"
   15 wm iconname $w "vscale"
   16 positionWindow $w
   17 
   18 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."
   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
   27 
   28 scale $w.frame.scale -orient vertical -length 284 -from 0 -to 250 \
   29     -command "setHeight $w.frame.canvas" -tickinterval 50
   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 SeaGreen3 -tags poly
   32 $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line
   33 frame $w.frame.right -borderwidth 15
   34 pack $w.frame.scale -side left -anchor ne
   35 pack $w.frame.canvas -side left -anchor nw -fill y
   36 $w.frame.scale set 75
   37 
   38 proc setHeight {w height} {
   39     incr height 21
   40     set y2 [expr {$height - 30}]
   41     if {$y2 < 21} {
   42     set y2 21
   43     }
   44     $w coords poly 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20
   45     $w coords line 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20
   46 }