STList1.tcl 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: STList1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
  4. #
  5. # Tix Demostration Program
  6. #
  7. # This sample program is structured in such a way so that it can be
  8. # executed from the Tix demo program "widget": it must have a
  9. # procedure called "RunSample". It should also have the "if" statment
  10. # at the end of this file so that it can be run as a standalone
  11. # program using tixwish.
  12. # Demonstrates the scrolled tlist widget
  13. #
  14. proc RunSample {w} {
  15. set top [frame $w.f -bd 1 -relief raised]
  16. set box [tixButtonBox $w.b -bd 1 -relief raised]
  17. pack $box -side bottom -fill both
  18. pack $top -side top -fill both -expand yes
  19. # Create the scrolled tlist
  20. #
  21. tixScrolledTList $top.st -options {
  22. tlist.orient vertical
  23. tlist.selectMode single
  24. }
  25. pack $top.st -expand yes -fill both -padx 10 -pady 10
  26. # Insert a list of numbers into the tlist subwidget
  27. #
  28. set tlist [$top.st subwidget tlist]
  29. set numbers {
  30. one two three fours five six seven eight nine ten eleven
  31. twelve thirdteen fourteen
  32. }
  33. foreach num $numbers {
  34. $tlist insert end -itemtype imagetext -text $num \
  35. -image [tix getimage openfold]
  36. }
  37. # Create the buttons
  38. #
  39. $box add ok -text Ok -command "destroy $w" -width 6
  40. $box add cancel -text Cancel -command "destroy $w" -width 6
  41. }
  42. if {![info exists tix_demo_running]} {
  43. wm withdraw .
  44. set w .demo
  45. toplevel $w; wm transient $w ""
  46. RunSample $w
  47. bind $w <Destroy> exit
  48. }