home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls088.hpux.Z / tls088.hpux / lib / vtcl / examples / align.tcl next >
Encoding:
Text File  |  1995-07-20  |  2.9 KB  |  90 lines

  1. #!/bin/vtcl
  2. # ---------------------------------------------------------------------
  3. # Copyright 1994 by SCO, Inc.
  4. # Permission to use, copy, modify, distribute, and sell this software
  5. # and its documentation for any purpose is hereby granted without fee,
  6. # provided that the above copyright notice appear in all copies and that
  7. # both that copyright  notice  and  this  permission  notice  appear  in
  8. # supporting documentation, and that the name  of  SCO  not  be used  in
  9. # advertising or publicity pertaining  to distribution of  the  software
  10. # without   specific,   written  prior   permission.    SCO   makes   no
  11. # representations  about  the  suitability  of  this  software  for  any
  12. # purpose.  It is provided "as is" without express or implied warranty.
  13. # ---------------------------------------------------------------------
  14.  
  15. # Demo        : align.tcl
  16. # Description    : Example usage of "WxAlignedForm"
  17. # Comments    : This demo shows how to use the convenience function
  18. #          "WxAlignedForm" to group a series of "label - widget"
  19. #          These convenience functions are stored in wserver.tlib
  20. #          located in ./lib/vtcl or ./lib/wserver.
  21. #          pairs to get a nice aligned, organized presentation.
  22. # Notes:    - look at the use of VtInfo to get display info. 
  23. #  
  24.  
  25. # Close connection and exit Vtcl interpreter.
  26. proc CloseCB { cbs } {
  27.     VtClose; exit
  28. }
  29.  
  30. # Callback that will echo (to stdout) the "type" of user
  31. # as indicated when using a toggle button in our form.
  32. proc EchoTypeCB {cbs} {
  33.     set widget [keylget cbs selectedWidget]
  34.  
  35.     # Don't echo to stdout if in character environment.
  36.     if { ! [VtInfo -charm] } {
  37.         echo "Type: [WxGetShortName $widget]"
  38.     }
  39. }
  40.  
  41. #
  42. # Open connection with Visual Tcl display engine
  43. #
  44. set app [VtOpen alignedDemo]
  45.  
  46. set dlog [VtFormDialog $app.dialog\
  47.     -title "Demo: Use of WxAlignedForm" \
  48.     -ok \
  49.     -okCallback CloseCB \
  50.     ]
  51.  
  52. # Pass a list of lists, where each list contains 
  53. #    1) the label, e.g. "Name:", and
  54. #    2) the widget command the label is to be associated with.
  55. #
  56. set form [WxAlignedForm $dlog.align\
  57.     { {"Name:"         {VtText -columns 15 -value "John Doe"}}
  58.       {"Address:"      {VtText -value "123 Hickory Street"}}
  59.       {"Phone Number:" {VtText -value "800-555-1212"}}
  60.       {"Status:"       {VtRadioBox -numColumns 3 -borderWidth 1}}}]
  61.  
  62. # attach the resulting form to the main dialog edges.
  63. VtSetValues $form \
  64.     -leftSide FORM \
  65.     -rightSide FORM 
  66.  
  67. # Note that the radiobox doesn't contain any buttons, yet.
  68. # To do so, we retrieve the name of the radiobox widget that was
  69. # assigned within the WxAlignedForm, using the index name "widget4"
  70. # since it was the 4th widget passed on the line.  (See the doc
  71. # on WxAlignedForm!)
  72. #
  73. set statusbox [WxGetVar $form "widget4"]
  74.  
  75. # assign a callback to the radiobox
  76. VtSetValues $statusbox \
  77.     -callback EchoTypeCB
  78.  
  79. # assign togglebuttons and their labels
  80. VtToggleButton $statusbox.friend \
  81.     -label "Friend" \
  82.     -value 1
  83. VtToggleButton $statusbox.enemy \
  84.     -label "Enemy"  
  85. VtToggleButton $statusbox.turkey\
  86.     -label "Turkey"    
  87.  
  88. VtShow $dlog
  89. VtMainLoop
  90.