Add a script to clean up after Tcl/Tk installation
[git/jnareb-git.git] / mingw / lib / tk8.5 / demos / button.tcl
blob84407f4457473805f25eb0b74d93938e1edf87e3
1 # button.tcl --
3 # This demonstration script creates a toplevel window containing
4 # several button widgets.
6 # RCS: @(#) $Id: button.tcl,v 1.9 2007/12/13 15:27:07 dgp Exp $
8 if {![info exists widgetDemo]} {
9 error "This script should be run from the \"widget\" demo."
12 package require Tk
14 set w .button
15 catch {destroy $w}
16 toplevel $w
17 wm title $w "Button Demonstration"
18 wm iconname $w "button"
19 positionWindow $w
21 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."
22 pack $w.msg -side top
24 ## See Code / Dismiss buttons
25 pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
27 proc 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
41 button $w.b1 -text "Peach Puff" -width 10 \
42 -command [list colorrefresh $w PeachPuff1]
43 button $w.b2 -text "Light Blue" -width 10 \
44 -command [list colorrefresh $w LightBlue1]
45 button $w.b3 -text "Sea Green" -width 10 \
46 -command [list colorrefresh $w SeaGreen2]
47 button $w.b4 -text "Yellow" -width 10 \
48 -command [list colorrefresh $w Yellow1]
49 pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 2