Update tk to version 8.5.9
[msysgit.git] / mingw / lib / tk8.5 / demos / ttkscale.tcl
blob5c0bdbec7cd6b8dbf16f69c79ab271482c2bb79a
1 # ttkscale.tcl --
3 # This demonstration script shows an example with a horizontal scale.
5 # RCS: @(#) $Id: ttkscale.tcl,v 1.1.2.2 2009/12/16 13:19:47 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 .ttkscale
14 catch {destroy $w}
15 toplevel $w -bg [ttk::style lookup TLabel -background]
16 wm title $w "Themed Scale Demonstration"
17 wm iconname $w "ttkscale"
18 positionWindow $w
20 pack [ttk::frame [set w $w.contents]] -fill both -expand 1
22 ttk::label $w.msg -font $font -wraplength 3.5i -justify left -text "A label tied to a horizontal scale is displayed below. If you click or drag mouse button 1 in the scale, you can change the contents of the label; a callback command is used to couple the slider to both the text and the coloring of the label."
23 pack $w.msg -side top -padx .5c
25 ## See Code / Dismiss buttons
26 set btns [addSeeDismiss $w.buttons [winfo toplevel $w]]
27 pack $btns -side bottom -fill x
29 ttk::frame $w.frame -borderwidth 10
30 pack $w.frame -side top -fill x
32 # List of colors from rainbox; "Indigo" is not a standard color
33 set colorList {Red Orange Yellow Green Blue Violet}
34 ttk::label $w.frame.label
35 ttk::scale $w.frame.scale -from 0 -to 5 -command [list apply {{w idx} {
36 set c [lindex $::colorList [tcl::mathfunc::int $idx]]
37 $w.frame.label configure -foreground $c -text "Color: $c"
38 }} $w]
39 # Trigger the setting of the label's text
40 $w.frame.scale set 0
41 pack $w.frame.label $w.frame.scale