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.

126 lines
4.2KB

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