Update tk to version 8.5.11
[git/jnareb-git.git] / mingw / lib / tk8.5 / demos / ttkscale.tcl
blob1a95416a4b1d8abac53d04886710c442ff3d9965
1 # ttkscale.tcl --
3 # This demonstration script shows an example with a horizontal scale.
5 if {![info exists widgetDemo]} {
6 error "This script should be run from the \"widget\" demo."
9 package require Tk
11 set w .ttkscale
12 catch {destroy $w}
13 toplevel $w -bg [ttk::style lookup TLabel -background]
14 wm title $w "Themed Scale Demonstration"
15 wm iconname $w "ttkscale"
16 positionWindow $w
18 pack [ttk::frame [set w $w.contents]] -fill both -expand 1
20 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."
21 pack $w.msg -side top -padx .5c
23 ## See Code / Dismiss buttons
24 set btns [addSeeDismiss $w.buttons [winfo toplevel $w]]
25 pack $btns -side bottom -fill x
27 ttk::frame $w.frame -borderwidth 10
28 pack $w.frame -side top -fill x
30 # List of colors from rainbox; "Indigo" is not a standard color
31 set colorList {Red Orange Yellow Green Blue Violet}
32 ttk::label $w.frame.label
33 ttk::scale $w.frame.scale -from 0 -to 5 -command [list apply {{w idx} {
34 set c [lindex $::colorList [tcl::mathfunc::int $idx]]
35 $w.frame.label configure -foreground $c -text "Color: $c"
36 }} $w]
37 # Trigger the setting of the label's text
38 $w.frame.scale set 0
39 pack $w.frame.label $w.frame.scale