states.tcl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # states.tcl --
  2. #
  3. # This demonstration script creates a listbox widget that displays
  4. # the names of the 50 states in the United States of America.
  5. if {![info exists widgetDemo]} {
  6. error "This script should be run from the \"widget\" demo."
  7. }
  8. package require Tk
  9. set w .states
  10. catch {destroy $w}
  11. toplevel $w
  12. wm title $w "Listbox Demonstration (50 states)"
  13. wm iconname $w "states"
  14. positionWindow $w
  15. label $w.msg -font $font -wraplength 4i -justify left -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 scanning. To scan, press button 2 in the widget and drag up or down."
  16. pack $w.msg -side top
  17. ## See Code / Dismiss buttons
  18. set btns [addSeeDismiss $w.buttons $w]
  19. pack $btns -side bottom -fill x
  20. frame $w.frame -borderwidth .5c
  21. pack $w.frame -side top -expand yes -fill y
  22. scrollbar $w.frame.scroll -command "$w.frame.list yview"
  23. listbox $w.frame.list -yscroll "$w.frame.scroll set" -setgrid 1 -height 12
  24. pack $w.frame.scroll -side right -fill y
  25. pack $w.frame.list -side left -expand 1 -fill both
  26. $w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \
  27. Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \
  28. Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \
  29. Massachusetts Michigan Minnesota Mississippi Missouri \
  30. Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \
  31. "New York" "North Carolina" "North Dakota" \
  32. Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \
  33. "South Carolina" "South Dakota" \
  34. Tennessee Texas Utah Vermont Virginia Washington \
  35. "West Virginia" Wisconsin Wyoming