gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.6KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: Tree.tcl,v 1.4 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. # This file demonstrates how to use the TixTree widget to display
  13. # hierachical data (A hypothetical DOS disk drive).
  14. #
  15. proc RunSample {w} {
  16. # We create the frame and the ScrolledHList widget
  17. # at the top of the dialog box
  18. #
  19. frame $w.top -relief raised -bd 1
  20. # Create a TixTree widget to display the hypothetical DOS disk drive
  21. #
  22. #
  23. tixTree $w.top.a -options {
  24. separator "\\"
  25. }
  26. pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left
  27. set tree $w.top.a
  28. set hlist [$w.top.a subwidget hlist]
  29. # STEP (1) Add the directories into the TixTree widget (using the
  30. # hlist subwidget)
  31. set directories {
  32. C:
  33. C:\\Dos
  34. C:\\Windows
  35. C:\\Windows\\System
  36. }
  37. foreach d $directories {
  38. set text [lindex [split $d \\] end]
  39. $hlist add $d -itemtype imagetext \
  40. -text $text -image [tix getimage folder]
  41. }
  42. # STEP (2) Use the "autosetmode" method of TixTree to indicate
  43. # which entries can be opened or closed. The
  44. # "autosetmode" command will call the "setmode" method
  45. # to set the mode of each entry to the following:
  46. #
  47. # "open" : the entry has some children and the children are
  48. # currently visible
  49. # "close": the entry has some children and the children are
  50. # currently INvisible
  51. # "none": the entry does not have children.
  52. #
  53. # If you don't like the "autosetmode" method, you can always call
  54. # "setmode" yourself, but that takes more work.
  55. $tree autosetmode
  56. # Use a ButtonBox to hold the buttons.
  57. #
  58. tixButtonBox $w.box -orientation horizontal
  59. $w.box add ok -text Ok -underline 0 -command "destroy $w" \
  60. -width 6
  61. $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
  62. -width 6
  63. pack $w.box -side bottom -fill x
  64. pack $w.top -side top -fill both -expand yes
  65. }
  66. # This "if" statement makes it possible to run this script file inside or
  67. # outside of the main demo program "widget".
  68. #
  69. if {![info exists tix_demo_running]} {
  70. wm withdraw .
  71. set w .demo
  72. toplevel $w; wm transient $w ""
  73. RunSample $w
  74. bind $w <Destroy> {if {"%W" == ".demo"} exit}
  75. }
上海开阖软件有限公司 沪ICP备12045867号-1