OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / lib / tk8.6 / demos / button.tcl
1 # button.tcl --
2 #
3 # This demonstration script creates a toplevel window containing
4 # several button widgets.
5
6 if {![info exists widgetDemo]} {
7     error "This script should be run from the \"widget\" demo."
8 }
9
10 package require Tk
11
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
18
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
21
22 ## See Code / Dismiss buttons
23 pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
24
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
34             }
35         }
36     }
37 }
38
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