Update tk to version 8.5.11
[git/jnareb-git.git] / mingw / lib / tk8.5 / demos / button.tcl
blobbb943e625c4b8d90cc696303424b510d835ea800
1 # button.tcl --
3 # This demonstration script creates a toplevel window containing
4 # several button widgets.
6 if {![info exists widgetDemo]} {
7 error "This script should be run from the \"widget\" demo."
10 package require Tk
12 set w .button
13 catch {destroy $w}
14 toplevel $w
15 wm title $w "Button Demonstration"
16 wm iconname $w "button"
17 positionWindow $w
19 label $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."
20 pack $w.msg -side top
22 ## See Code / Dismiss buttons
23 pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
25 proc colorrefresh {w col} {
26 $w configure -bg $col
27 if {[tk windowingsystem] eq "aqua"} {
28 # set highlightbackground of all buttons in $w
29 set l [list $w]
30 while {[llength $l]} {
31 set l [concat [lassign $l b] [winfo children $b]]
32 if {[winfo class $b] eq "Button"} {
33 $b configure -highlightbackground $col
39 button $w.b1 -text "Peach Puff" -width 10 \
40 -command [list colorrefresh $w PeachPuff1]
41 button $w.b2 -text "Light Blue" -width 10 \
42 -command [list colorrefresh $w LightBlue1]
43 button $w.b3 -text "Sea Green" -width 10 \
44 -command [list colorrefresh $w SeaGreen2]
45 button $w.b4 -text "Yellow" -width 10 \
46 -command [list colorrefresh $w Yellow1]
47 pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 2