3
# Create a top-level window that displays a listbox with the names of the
7
# w - Name to use for new top-level window.
9
proc mkListbox {{w .l1}} {
13
wm title $w "Listbox Demonstration (50 states)"
14
wm iconname $w "Listbox"
17
message $w.msg -font -Adobe-times-medium-r-normal--*-180* -aspect 300 \
18
-text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by dragging in the listbox window with button 2 pressed. Click the \"OK\" button when you've seen enough."
19
frame $w.frame -borderwidth 10
20
button $w.ok -text OK -command "destroy $w"
22
pack $w.frame -side top -expand yes -fill y
23
pack $w.ok -side bottom -fill x
25
scrollbar $w.frame.scroll -relief sunken -command "$w.frame.list yview"
26
listbox $w.frame.list -yscroll "$w.frame.scroll set" -relief sunken \
28
pack $w.frame.scroll -side right -fill y
29
pack $w.frame.list -side left -expand yes -fill both
31
$w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \
32
Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \
33
Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \
34
Massachusetts Michigan Minnesota Mississippi Missouri \
35
Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \
36
"New York" "North Carolina" "North Dakota" \
37
Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \
38
"South Carolina" "South Dakota" \
39
Tennessee Texas Utah Vermont Virginia Washington \
40
"West Virginia" Wisconsin Wyoming