STList2.tcl 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: STList2.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 Paned Window to contain two scrolled tlist's
  20. #
  21. set p [tixPanedWindow $top.p -orient horizontal]
  22. pack $p -expand yes -fill both -padx 4 -pady 4
  23. set p1 [$p add pane1 -expand 1]
  24. set p2 [$p add pane2 -expand 1]
  25. $p1 config -relief flat
  26. $p2 config -relief flat
  27. # Create a TList with vertical orientation
  28. #
  29. tixScrolledTList $p1.st -options {
  30. tlist.orient vertical
  31. tlist.selectMode single
  32. }
  33. label $p1.lab -text "Vertical Orientation"
  34. pack $p1.lab -anchor c -side top -pady 2
  35. pack $p1.st -expand yes -fill both -padx 10 -pady 10
  36. # Create a TList with horizontal orientation
  37. #
  38. tixScrolledTList $p2.st -options {
  39. tlist.orient horizontal
  40. tlist.selectMode single
  41. }
  42. label $p2.lab -text "Horizontal Orientation"
  43. pack $p2.lab -anchor c -side top -pady 2
  44. pack $p2.st -expand yes -fill both -padx 10 -pady 10
  45. # Insert a list of numbers into the two tlist subwidget's
  46. #
  47. set vt [$p1.st subwidget tlist]
  48. set ht [$p2.st subwidget tlist]
  49. set numbers {
  50. one two three fours five six seven eight nine ten eleven
  51. twelve thirdteen fourteen
  52. }
  53. foreach num $numbers {
  54. $vt insert end -itemtype imagetext -text $num \
  55. -image [tix getimage openfold]
  56. $ht insert end -itemtype imagetext -text $num \
  57. -image [tix getimage openfold]
  58. }
  59. # Create the buttons
  60. #
  61. $box add ok -text Ok -command "destroy $w" -width 6
  62. $box add cancel -text Cancel -command "destroy $w" -width 6
  63. }
  64. if {![info exists tix_demo_running]} {
  65. wm withdraw .
  66. set w .demo
  67. toplevel $w; wm transient $w ""
  68. RunSample $w
  69. bind $w <Destroy> exit
  70. }