]>
Commit | Line | Data |
---|---|---|
1 | # mkListbox w | |
2 | # | |
3 | # Create a top-level window that displays a listbox with the names of the | |
4 | # 50 states. | |
5 | # | |
6 | # Arguments: | |
7 | # w - Name to use for new top-level window. | |
8 | ||
9 | proc mkListbox {{w .l1}} { | |
10 | catch {destroy $w} | |
11 | toplevel $w | |
12 | dpos $w | |
13 | wm title $w "Listbox Demonstration (50 states)" | |
14 | wm iconname $w "Listbox" | |
15 | message $w.msg -font -Adobe-times-medium-r-normal--*-180* -aspect 300 \ | |
16 | -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." | |
17 | frame $w.frame -borderwidth 10 | |
18 | pack append $w.frame \ | |
19 | [scrollbar $w.frame.scroll -relief sunken \ | |
20 | -command "$w.frame.list yview"] {right expand filly frame w} \ | |
21 | [listbox $w.frame.list -yscroll "$w.frame.scroll set" -relief sunken] \ | |
22 | {left expand filly frame e} | |
23 | $w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \ | |
24 | Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \ | |
25 | Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \ | |
26 | Massachusetts Michigan Minnesota Mississippi Missouri \ | |
27 | Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \ | |
28 | "New York" "North Carolina" "North Dakota" \ | |
29 | Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \ | |
30 | "South Carolina" "South Dakota" \ | |
31 | Tennessee Texas Utah Vermont Virginia Washington \ | |
32 | "West Virginia" Wisconsin Wyoming | |
33 | button $w.ok -text OK -command "destroy $w" | |
34 | ||
35 | pack append $w $w.msg {top fill} $w.frame {top expand fill} \ | |
36 | $w.ok {bottom fill} | |
37 | } |