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.

95 lines
2.7KB

  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: LabEntry.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 tixLabelEntry widget -- an entry that
  13. # come with a label at its side, so you don't need to create
  14. # extra frames on your own and do the messy hierarchical packing. This
  15. # example is adapted from the tixControl example, except now you don't
  16. # have arrow buttons to adjust the values for you ...
  17. #
  18. proc RunSample {w} {
  19. # Create the tixLabelEntrys on the top of the dialog box
  20. #
  21. frame $w.top -border 1 -relief raised
  22. # $w.top.a allows only integer values
  23. #
  24. # [Hint] The -options switch sets the options of the subwidgets.
  25. # [Hint] We set the label.width subwidget option of the Controls to
  26. # be 16 so that their labels appear to be aligned.
  27. #
  28. global lent_demo_maker lent_demo_thrust lent_demo_num_engins
  29. set lent_demo_maker P&W
  30. set lent_demo_thrust 20000.0
  31. set lent_demo_num_engins 2
  32. tixLabelEntry $w.top.a -label "Number of Engines: " \
  33. -options {
  34. entry.width 10
  35. label.width 20
  36. label.anchor e
  37. entry.textVariable lent_demo_num_engins
  38. }
  39. tixLabelEntry $w.top.b -label "Thrust: "\
  40. -options {
  41. entry.width 10
  42. label.width 20
  43. label.anchor e
  44. entry.textVariable lent_demo_thrust
  45. }
  46. tixLabelEntry $w.top.c -label "Engin Maker: " \
  47. -options {
  48. entry.width 10
  49. label.width 20
  50. label.anchor e
  51. entry.textVariable lent_demo_maker
  52. }
  53. pack $w.top.a $w.top.b $w.top.c -side top -anchor w
  54. # Use a ButtonBox to hold the buttons.
  55. #
  56. tixButtonBox $w.box -orientation horizontal
  57. $w.box add ok -text Ok -underline 0 -command "labe:okcmd $w" \
  58. -width 6
  59. $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
  60. -width 6
  61. pack $w.box -side bottom -fill x
  62. pack $w.top -side top -fill both -expand yes
  63. }
  64. proc labe:okcmd {w} {
  65. global lent_demo_maker lent_demo_thrust lent_demo_num_engins
  66. tixDemo:Status "You selected $lent_demo_num_engins engin(s) of thrust $lent_demo_thrust made \
  67. by $lent_demo_maker"
  68. destroy $w
  69. }
  70. # This "if" statement makes it possible to run this script file inside or
  71. # outside of the main demo program "widget".
  72. #
  73. if {![info exists tix_demo_running]} {
  74. wm withdraw .
  75. set w .demo
  76. toplevel $w; wm transient $w ""
  77. RunSample $w
  78. bind $w <Destroy> exit
  79. }
上海开阖软件有限公司 沪ICP备12045867号-1