OSDN Git Service

224d8f95a30a3dd1c5e3edd997fe140307948651
[stux/ultron.git] / venv / tcl / tk8.6 / demos / icon.tcl
1 # icon.tcl --
2 #
3 # This demonstration script creates a toplevel window containing
4 # buttons that display bitmaps instead of text.
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 .icon
13 catch {destroy $w}
14 toplevel $w
15 wm title $w "Iconic Button Demonstration"
16 wm iconname $w "icon"
17 positionWindow $w
18
19 label $w.msg -font $font -wraplength 5i -justify left -text "This window shows three ways of using bitmaps or images in radiobuttons and checkbuttons.  On the left are two radiobuttons, each of which displays a bitmap and an indicator.  In the middle is a checkbutton that displays a different image depending on whether it is selected or not.  On the right is a checkbutton that displays a single bitmap but changes its background color to indicate whether or not it is selected."
20 pack $w.msg -side top
21
22 ## See Code / Dismiss buttons
23 set btns [addSeeDismiss $w.buttons $w]
24 pack $btns -side bottom -fill x
25
26 # Main widget program sets variable tk_demoDirectory
27 image create bitmap flagup \
28         -file [file join $tk_demoDirectory images flagup.xbm] \
29         -maskfile [file join $tk_demoDirectory images flagup.xbm]
30 image create bitmap flagdown \
31         -file [file join $tk_demoDirectory images flagdown.xbm] \
32         -maskfile [file join $tk_demoDirectory images flagdown.xbm]
33 frame $w.frame -borderwidth 10
34 pack $w.frame -side top
35
36 checkbutton $w.frame.b1 -image flagdown -selectimage flagup \
37         -indicatoron 0
38 $w.frame.b1 configure -selectcolor [$w.frame.b1 cget -background]
39 checkbutton $w.frame.b2 \
40         -bitmap @[file join $tk_demoDirectory images letters.xbm] \
41         -indicatoron 0 -selectcolor SeaGreen1
42 frame $w.frame.left
43 pack $w.frame.left $w.frame.b1 $w.frame.b2 -side left -expand yes -padx 5m
44
45 radiobutton $w.frame.left.b3 \
46         -bitmap @[file join $tk_demoDirectory images letters.xbm] \
47         -variable letters -value full
48 radiobutton $w.frame.left.b4 \
49         -bitmap @[file join $tk_demoDirectory images noletter.xbm] \
50         -variable letters -value empty
51 pack $w.frame.left.b3 $w.frame.left.b4 -side top -expand yes