Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / lib / tk8.4 / demos / clrpick.tcl
blob5c1f0181954a404dec00d733e79f55c7fb75255a
1 # clrpick.tcl --
3 # This demonstration script prompts the user to select a color.
5 # RCS: @(#) $Id: clrpick.tcl,v 1.3 2001/06/14 10:56:58 dkf Exp $
7 if {![info exists widgetDemo]} {
8 error "This script should be run from the \"widget\" demo."
11 set w .clrpick
12 catch {destroy $w}
13 toplevel $w
14 wm title $w "Color Selection Dialog"
15 wm iconname $w "colors"
16 positionWindow $w
18 label $w.msg -font $font -wraplength 4i -justify left -text "Press the buttons below to choose the foreground and background colors for the widgets in this window."
19 pack $w.msg -side top
21 frame $w.buttons
22 pack $w.buttons -side bottom -fill x -pady 2m
23 button $w.buttons.dismiss -text Dismiss -command "destroy $w"
24 button $w.buttons.code -text "See Code" -command "showCode $w"
25 pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
27 button $w.back -text "Set background color ..." \
28 -command \
29 "setColor $w $w.back background {-background -highlightbackground}"
30 button $w.fore -text "Set foreground color ..." \
31 -command \
32 "setColor $w $w.back foreground -foreground"
34 pack $w.back $w.fore -side top -anchor c -pady 2m
36 proc setColor {w button name options} {
37 grab $w
38 set initialColor [$button cget -$name]
39 set color [tk_chooseColor -title "Choose a $name color" -parent $w \
40 -initialcolor $initialColor]
41 if {[string compare $color ""]} {
42 setColor_helper $w $options $color
44 grab release $w
47 proc setColor_helper {w options color} {
48 foreach option $options {
49 catch {
50 $w config $option $color
53 foreach child [winfo children $w] {
54 setColor_helper $child $options $color