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.

137 lines
4.4KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: CmpImg2.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. # This file demonstrates how to use the compound image inside NoteBook
  13. # widgets. This file is basically a cross-over of NoteBook.tcl and CmpImg.tcl
  14. #
  15. proc RunSample {w} {
  16. # Create the notebook widget and set its backpagecolor to gray.
  17. # Note that the -backpagecolor option belongs to the "nbframe"
  18. # subwidget.
  19. tixNoteBook $w.nb -ipadx 6 -ipady 6
  20. $w config -bg gray
  21. $w.nb subwidget nbframe config -backpagecolor gray -tabpady 0
  22. # Create the two compound images
  23. #
  24. #
  25. # these are two Tix built-in images
  26. #
  27. set img0 [tix getimage network]
  28. set img1 [tix getimage harddisk]
  29. # Create the first image:
  30. #
  31. # Notice that the -window option must be set to the nbframe
  32. # subwidget of the notebook because the image will be displayed
  33. # in that widget.
  34. #
  35. set hdd_img [image create compound -window [$w.nb subwidget nbframe] \
  36. -pady 0]
  37. $hdd_img add line
  38. $hdd_img add image -image $img1
  39. $hdd_img add space -width 7
  40. $hdd_img add text -text "Hard Disk" -underline 0
  41. # Create the second compound image. Very similar to what we did above
  42. #
  43. set net_img [image create compound -window [$w.nb subwidget nbframe] \
  44. -pady 0]
  45. $net_img add line
  46. $net_img add image -image $img0
  47. $net_img add space -width 7
  48. $net_img add text -text "Network" -underline 0
  49. #
  50. # Now create the pages
  51. #
  52. # We use these options to set the sizes of the subwidgets inside the
  53. # notebook, so that they are well-aligned on the screen.
  54. #
  55. set name [tixOptionName $w]
  56. option add *$name*TixControl*entry.width 10
  57. option add *$name*TixControl*label.width 18
  58. option add *$name*TixControl*label.anchor e
  59. # Create the two tabs on the notebook. The -underline option
  60. # puts a underline on the first character of the labels of the tabs.
  61. # Keyboard accelerators will be defined automatically according
  62. # to the underlined character.
  63. #
  64. $w.nb add hard_disk -image $hdd_img
  65. $w.nb add network -image $net_img
  66. pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
  67. #----------------------------------------
  68. # Create the first page
  69. #----------------------------------------
  70. set f [$w.nb subwidget hard_disk]
  71. # Create two frames: one for the common buttons, one for the
  72. # other widgets
  73. #
  74. frame $f.f
  75. frame $f.common
  76. pack $f.f -side left -padx 2 -pady 2 -fill both -expand yes
  77. pack $f.common -side right -padx 2 -pady 2 -fill y
  78. # Create the controls that only belong to this page
  79. #
  80. tixControl $f.f.a -value 12 -label "Access Time: "
  81. tixControl $f.f.w -value 400 -label "Write Throughput: "
  82. tixControl $f.f.r -value 400 -label "Read Throughput: "
  83. tixControl $f.f.c -value 1021 -label "Capacity: "
  84. pack $f.f.a $f.f.w $f.f.r $f.f.c -side top -padx 20 -pady 2
  85. # Create the common buttons
  86. #
  87. CreateCommonButtons $w $f.common
  88. #----------------------------------------
  89. # Create the second page
  90. #----------------------------------------
  91. set f [$w.nb subwidget network]
  92. frame $f.f
  93. frame $f.common
  94. pack $f.f -side left -padx 2 -pady 2 -fill both -expand yes
  95. pack $f.common -side right -padx 2 -pady 2 -fill y
  96. tixControl $f.f.a -value 12 -label "Access Time: "
  97. tixControl $f.f.w -value 400 -label "Write Throughput: "
  98. tixControl $f.f.r -value 400 -label "Read Throughput: "
  99. tixControl $f.f.c -value 1021 -label "Capacity: "
  100. tixControl $f.f.u -value 10 -label "Users: "
  101. pack $f.f.a $f.f.w $f.f.r $f.f.c $f.f.u -side top -padx 20 -pady 2
  102. CreateCommonButtons $w $f.common
  103. }
  104. proc CreateCommonButtons {w f} {
  105. button $f.ok -text OK -width 6 -command "destroy $w"
  106. button $f.cancel -text Cancel -width 6 -command "destroy $w"
  107. pack $f.ok $f.cancel -side top -padx 2 -pady 2
  108. }
  109. if {![info exists tix_demo_running]} {
  110. wm withdraw .
  111. set w .demo
  112. toplevel $w; wm transient $w ""
  113. RunSample $w
  114. bind $w <Destroy> exit
  115. }
上海开阖软件有限公司 沪ICP备12045867号-1