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.

115 lines
3.2KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: Select.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 the use of the tixSelect widget.
  13. #
  14. proc RunSample {w} {
  15. global demo_dir
  16. # Create the frame on the top of the dialog box with two tixSelect
  17. # widgets inside.
  18. #
  19. frame $w.top
  20. # There can be one and only type of justification for any piece of text.
  21. # So we set -radio to be true. Also, -allowzero is set to false: the user
  22. # cannot select a "none" justification
  23. #
  24. tixSelect $w.top.just -allowzero false -radio true \
  25. -label "Justification: "\
  26. -options {
  27. label.width 15
  28. label.padx 4
  29. label.anchor e
  30. }
  31. # The user can select one or many or none of the font attributes in
  32. # the font Select widget, so we set -radio to false (can select one or
  33. # many) and -allowzero to true (can select none)
  34. #
  35. tixSelect $w.top.font -allowzero true -radio false \
  36. -label "Font: " \
  37. -options {
  38. label.width 15
  39. label.padx 4
  40. label.anchor e
  41. }
  42. pack $w.top.just $w.top.font -side top -expand yes -anchor c \
  43. -padx 4 -pady 4
  44. # Add the choices of available font attributes
  45. #
  46. #
  47. $w.top.font add bold -bitmap @$demo_dir/bitmaps/bold.xbm
  48. $w.top.font add italic -bitmap @$demo_dir/bitmaps/italic.xbm
  49. $w.top.font add underline -bitmap @$demo_dir/bitmaps/underlin.xbm
  50. $w.top.font add capital -bitmap @$demo_dir/bitmaps/capital.xbm
  51. # Add the choices of available justification types
  52. #
  53. #
  54. $w.top.just add left -bitmap @$demo_dir/bitmaps/leftj.xbm
  55. $w.top.just add right -bitmap @$demo_dir/bitmaps/rightj.xbm
  56. $w.top.just add center -bitmap @$demo_dir/bitmaps/centerj.xbm
  57. $w.top.just add justified -bitmap @$demo_dir/bitmaps/justify.xbm
  58. $w.top.font config -variable sel_font
  59. $w.top.just config -variable sel_just
  60. # Set the default value of the two Select widgets
  61. #
  62. #
  63. global sel_just sel_font
  64. set sel_just justified
  65. set sel_font {bold underline}
  66. # Use a ButtonBox to hold the buttons.
  67. #
  68. tixButtonBox $w.box -orientation horizontal
  69. $w.box add ok -text Ok -underline 0 -width 6\
  70. -command "sel:cmd $w; destroy $w"
  71. $w.box add apply -text Apply -underline 0 -width 6\
  72. -command "sel:cmd $w"
  73. $w.box add cancel -text Cancel -underline 0 -width 6\
  74. -command "destroy $w"
  75. pack $w.box -side bottom -fill x
  76. pack $w.top -side top -fill both -expand yes
  77. }
  78. # This procedure is called whenever the user pressed the OK or the Apply button
  79. #
  80. #
  81. proc sel:cmd {w} {
  82. global sel_font sel_just
  83. tixDemo:Status "The justification is $sel_just"
  84. if {$sel_font == {}} {
  85. tixDemo:Status "The font is normal"
  86. } else {
  87. tixDemo:Status "The font is $sel_font"
  88. }
  89. }
  90. if {![info exists tix_demo_running]} {
  91. wm withdraw .
  92. set w .demo
  93. toplevel $w; wm transient $w ""
  94. RunSample $w
  95. bind .demo <Destroy> exit
  96. }
上海开阖软件有限公司 沪ICP备12045867号-1