1# button.tcl --
2#
3# This demonstration script creates a toplevel window containing
4# several button widgets.
5#
6# RCS: @(#) $Id$
7
8if {![info exists widgetDemo]} {
9    error "This script should be run from the \"widget\" demo."
10}
11
12package require Tk
13
14set w .button
15catch {destroy $w}
16toplevel $w
17wm title $w "Button Demonstration"
18wm iconname $w "button"
19positionWindow $w
20
21label $w.msg -font $font -wraplength 4i -justify left -text "If you click on any of the four buttons below, the background of the button area will change to the color indicated in the button.  You can press Tab to move among the buttons, then press Space to invoke the current button."
22pack $w.msg -side top
23
24## See Code / Dismiss buttons
25pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
26
27proc colorrefresh {w col} {
28    $w configure -bg $col
29    if {[tk windowingsystem] eq "aqua"} {
30	# set highlightbackground of all buttons in $w
31	set l [list $w]
32	while {[llength $l]} {
33	    set l [concat [lassign $l b] [winfo children $b]]
34	    if {[winfo class $b] eq "Button"} {
35		$b configure -highlightbackground $col
36	    }
37	}
38    }
39}
40
41button $w.b1 -text "Peach Puff" -width 10 \
42    -command [list colorrefresh $w PeachPuff1]
43button $w.b2 -text "Light Blue" -width 10 \
44    -command [list colorrefresh $w LightBlue1]
45button $w.b3 -text "Sea Green" -width 10 \
46    -command [list colorrefresh $w SeaGreen2]
47button $w.b4 -text "Yellow" -width 10 \
48    -command [list colorrefresh $w Yellow1]
49pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 2
50