home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / TCL / BLT / _BLT.TAR / usr / lib / blt / demos / htext.txt < prev    next >
Encoding:
Text File  |  1994-04-07  |  19.8 KB  |  600 lines

  1.         This is a (for lack of a better name) hypertext widget.
  2.  
  3. This widget combines text and other Tk widgets in the same window. 
  4. It is sort of a cross between a read-only text widget and the pack command.  
  5. Any widget can be attached to the hypertext window by the %% 
  6. label $blt_htext(widget).lab -text "append " -relief sunken \
  7.         -font *-Courier-Bold-R-Normal-*-120-*
  8. $blt_htext(widget) append $blt_htext(widget).lab 
  9. %% command.
  10. For example, 
  11. %% message $blt_htext(widget).msg -relief sunken -bd 2 -aspect 10000 -font \
  12.  *-Courier-Medium-R-Normal-*-120-* -text {set w $blt_htext(widget)
  13. label $w.face -bitmap @bitmaps/face \ 
  14.   -relief sunken -borderwidth 2
  15. $w append $w.face -padx 2 -pady 0.25i}
  16. $blt_htext(widget) append $blt_htext(widget).msg \
  17.         -fill both %% added this %%
  18. global tk_library
  19. label $blt_htext(widget).face \
  20.         -bitmap @$tk_library/demos/bitmaps/face  \
  21.         -relief sunken -borderwidth 2
  22. $blt_htext(widget) append $blt_htext(widget).face -padx 2 -pady 0.25i -fill both
  23. %%.
  24. There can be many types of widgets in the same document.  For example,
  25. this is a simple %% 
  26. button $blt_htext(widget).but -bg pink -text { button } \
  27.         -command { puts stderr { a stupid message } } 
  28. $blt_htext(widget) append $blt_htext(widget).but
  29. %%. If you click on the button, it prints a stupid message. 
  30. Any Tk widget can be used, including %%
  31. checkbutton $blt_htext(widget).ckbut -bg lightblue -text { check buttons } \
  32.         -command { puts stderr { check button pressed } } 
  33. $blt_htext(widget) append $blt_htext(widget).ckbut
  34. %%, %%
  35. radiobutton $blt_htext(widget).rdbut -bg mediumseagreen -text { radio buttons } \
  36.         -command { puts stderr { radio button pressed } } 
  37. $blt_htext(widget) append $blt_htext(widget).rdbut
  38. %%, 
  39. and scales %%
  40. scale $blt_htext(widget).sc -showvalue true \
  41.         -length 100 \
  42.         -sliderforeground powderblue \
  43.         -sliderlength 10 \
  44.         -orient horizontal  
  45. $blt_htext(widget) append $blt_htext(widget).sc
  46. %%.  
  47.  
  48.         Widget trees can be also be included. The following example is 
  49. *borrowed* from the widget demo. It is a couple of frames surrounding a 
  50. listbox, a message, and a button widget. 
  51. %%
  52.     set w $blt_htext(widget).frame 
  53.     frame $w 
  54.     message $w.msg -font *times-medium-r-normal--*-120* -aspect 300 \
  55.             -text "A listbox containing the 50 states is displayed below, along with a scrollbar.  You can scan the list either using the scrollbar or by dragging in the listbox window with button 3 pressed.  Click the \"OK\" button when you've seen enough." -bg lightsteelblue -relief sunken
  56.     frame $w.frame -borderwidth 10 
  57.     pack append $w.frame \
  58.         [scrollbar $w.frame.scroll -relief sunken \
  59.             -command "$w.frame.list yview"] {right expand filly frame w} \
  60.         [listbox $w.frame.list -yscroll "$w.frame.scroll set" -relief sunken] \
  61.             {left expand filly frame e}
  62.     $w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \
  63.         Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \
  64.         Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \
  65.         Massachusetts Michigan Minnesota Mississippi Missouri \
  66.         Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \
  67.         "New York" "North Carolina" "North Dakota" \
  68.         Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \
  69.         "South Carolina" "South Dakota" \
  70.         Tennessee Texas Utah Vermont Virginia Washington \
  71.         "West Virginia" Wisconsin Wyoming
  72.     button $w.ok -text OK -command "puts stderr $w; destroy $w"
  73.  
  74.     pack append $w $w.msg {top fill} $w.frame {top expand fill} \
  75.         $w.ok {bottom fill}
  76.     $w config -bg lightsteelblue -relief sunken
  77.  
  78. $blt_htext(widget) append $w -padx 1.0i -pady 0.25i
  79. %% 
  80.  
  81. You can add you own home-grown widgets.  Here's the blt_graph widget.
  82. Beside it is the "color" demo.  Moving the scales, adjusts the background
  83. color of the graph.
  84. %%
  85. proc makeplot { widget } {
  86.  
  87.     set X { 
  88.         2.00000e-01 4.00000e-01 6.00000e-01 8.00000e-01 1.00000e+00 
  89.         1.20000e+00 1.40000e+00 1.60000e+00 1.80000e+00 2.00000e+00 
  90.         2.20000e+00 2.40000e+00 2.60000e+00 2.80000e+00 3.00000e+00 
  91.         3.20000e+00 3.40000e+00 3.60000e+00 3.80000e+00 4.00000e+00 
  92.         4.20000e+00 4.40000e+00 4.60000e+00 4.80000e+00 5.00000e+00 
  93.     } 
  94.  
  95.     $widget element create Y1 -xdata $X -ydata { 
  96.         1.14471e+01 2.09373e+01 2.84608e+01 3.40080e+01 3.75691e+01 
  97.         3.91345e+01 3.92706e+01 3.93474e+01 3.94242e+01 3.95010e+01 
  98.         3.95778e+01 3.96545e+01 3.97313e+01 3.98081e+01 3.98849e+01 
  99.         3.99617e+01 4.00384e+01 4.01152e+01 4.01920e+01 4.02688e+01 
  100.         4.03455e+01 4.04223e+01 4.04990e+01 4.05758e+01 4.06526e+01 
  101.     } -symbol line -linewidth 0 -label VGS=2.0 -fg blue 
  102.  
  103.     $widget element create a -xdata $X -ydata { 
  104.         2.61825e+01 5.04696e+01 7.28517e+01 9.33192e+01 1.11863e+02 
  105.         1.28473e+02 1.43140e+02 1.55854e+02 1.66606e+02 1.75386e+02 
  106.         1.82185e+02 1.86994e+02 1.89802e+02 1.90683e+02 1.91047e+02 
  107.         1.91411e+02 1.91775e+02 1.92139e+02 1.92503e+02 1.92867e+02 
  108.         1.93231e+02 1.93595e+02 1.93958e+02 1.94322e+02 1.94686e+02 
  109.     } -symbol cross -linewidth 0 -fg brown 
  110.  
  111.     $widget element create Y2 -xdata $X -ydata { 
  112.         2.61825e+01 5.04696e+01 7.28517e+01 9.33192e+01 1.11863e+02 
  113.         1.28473e+02 1.43140e+02 1.55854e+02 1.66606e+02 1.75386e+02 
  114.         1.82185e+02 1.86994e+02 1.89802e+02 1.90683e+02 1.91047e+02 
  115.         1.91411e+02 1.91775e+02 1.92139e+02 1.92503e+02 1.92867e+02 
  116.         1.93231e+02 1.93595e+02 1.93958e+02 1.94322e+02 1.94686e+02 
  117.     } -symbol line -linewidth 0 -label VGS=3.5 -fg green 
  118.  
  119.     $widget element create Y3 -xdata $X -ydata { 
  120.         4.07008e+01 7.95658e+01 1.16585e+02 1.51750e+02 1.85051e+02 
  121.         2.16479e+02 2.46024e+02 2.73676e+02 2.99427e+02 3.23267e+02 
  122.         3.45187e+02 3.65177e+02 3.83228e+02 3.99331e+02 4.13476e+02 
  123.         4.25655e+02 4.35856e+02 4.44073e+02 4.50294e+02 4.54512e+02 
  124.         4.56716e+02 4.57596e+02 4.58448e+02 4.59299e+02 4.60151e+02 
  125.    } -symbol line -linewidth 0  -label VGS=5.0 -fg red 
  126.  
  127.     $widget element create t -xdata $X -ydata { 
  128.         4.07008e+01 7.95658e+01 1.16585e+02 1.51750e+02 1.85051e+02 
  129.         2.16479e+02 2.46024e+02 2.73676e+02 2.99427e+02 3.23267e+02 
  130.         3.45187e+02 3.65177e+02 3.83228e+02 3.99331e+02 4.13476e+02 
  131.         4.25655e+02 4.35856e+02 4.44073e+02 4.50294e+02 4.54512e+02 
  132.         4.56716e+02 4.57596e+02 4.58448e+02 4.59299e+02 4.60151e+02 
  133.    } -symbol plus -linewidth 0  -fg purple 
  134. }
  135.  
  136. option add *Blt_graph.title  "Plot Title" 
  137. option add *Blt_graph.xTitle "X Axis Label"
  138. option add *Blt_graph.yTitle "Y Axis Label" 
  139. option add *Blt_graph.legendMapped false 
  140. option add *Blt_graph.relief ridge
  141. option add *Blt_graph.borderWidth 2
  142.  
  143. blt_graph $blt_htext(widget).g -width 200 -height 200 
  144. #-xlog true -ylog true
  145. makeplot $blt_htext(widget).g
  146. $blt_htext(widget) append $blt_htext(widget).g -padx 0.25i -pady 0.25i
  147.  
  148. %% %%
  149. #
  150. # Simple script to change colors of a window.
  151. #
  152. global xlabel ylabel red green blue grph
  153. set xlabel $blt_htext(widget).xlab
  154. set ylabel $blt_htext(widget).ylab
  155. set grph $blt_htext(widget).g
  156. set w $blt_htext(widget).cf
  157. set red 0
  158. set green 0
  159. set blue 0
  160.  
  161. option add *Scale.sliderForeground "#cdb79e"
  162. option add *Scale.activeForeground "#ffe4c4"
  163. frame $w
  164. scale $w.red -command "color red" -label "Red Intensity" \
  165.         -from 0 -to 255 -orient horizontal -bg "#ffaeb9" -length 250
  166. scale $w.green -command "color green" -label "Green Intensity" \
  167.         -from 0 -to 255 -orient horizontal -bg "#43cd80"
  168. scale $w.blue -command "color blue" -label "Blue Intensity"  \
  169.         -from 0 -to 255 -orient horizontal -bg "#7ec0ee"
  170. pack append $w $w.red {top expand fill}
  171. pack append $w $w.green {top expand fill}
  172. pack append $w $w.blue {top expand fill}
  173.  
  174. proc color {which intensity} {
  175.     global red green blue grph xlabel ylabel
  176.     set $which $intensity
  177.     set rgb [format #%02x%02x%02x $red $green $blue]
  178.     $grph config -bg $rgb
  179.     $xlabel config -bg $rgb
  180.     $ylabel config -bg $rgb
  181. }
  182.  
  183. $blt_htext(widget) append $w
  184.  
  185. %%
  186. If you click on any button in the graph, you will get the coordinate 
  187. values at the pointer location.  
  188.  
  189. The current coordinate values are %%
  190. label $blt_htext(widget).xlab -text { ??? ??? } -relief sunken
  191. label $blt_htext(widget).ylab -text { ??? ??? } -relief sunken
  192. bind $blt_htext(widget).g <ButtonPress> {labelxy [ %W invtransform %x %y ]}
  193.  
  194. proc labelxy { values } {
  195.     global xlabel ylabel
  196.     scan $values "%e %e" x y
  197.     $xlabel config -text $x
  198.     $ylabel config -text $y
  199. }
  200. $blt_htext(widget) append $blt_htext(widget).xlab -width 100 -fill x
  201. %% and %%
  202. $blt_htext(widget) append $blt_htext(widget).ylab -width 100 -fill x
  203. %%.
  204.  
  205.  
  206. There are three global variables automatically created when a hypertext
  207. file is read:
  208.  
  209.         %% 
  210. button $blt_htext(widget).l1 -text "\$blt_htext(widget)" -command "puts stdout $blt_htext(widget)" 
  211. $blt_htext(widget) append $blt_htext(widget).l1 %% is the pathname of the hypertext widget. 
  212.         %% 
  213. button $blt_htext(widget).l2 -text "\$blt_htext(file)" -command "puts stdout $blt_htext(file)" 
  214. $blt_htext(widget) append $blt_htext(widget).l2
  215. %% is the file being read and 
  216.         %% 
  217. button $blt_htext(widget).l3 -text "\$blt_htext(line)"  -command "puts stdout $blt_htext(line)"
  218. $blt_htext(widget) append l3
  219. %% is the current line number.
  220.  
  221. Click on any button and the current value is printed on standard output.
  222.  
  223. The hypertext widget works with plain text too. If you don't want
  224. to read it, click on the %% 
  225. button $blt_htext(widget).goto -text button -fg purple -bg white \
  226.         -command "global endOfText; $blt_htext(widget) gotoline \$endOfText"
  227. $blt_htext(widget) append $blt_htext(widget).goto
  228. %% to jump to the end of the plain text.
  229.  
  230.          ------------------------------------------------------
  231.  
  232. This is version 1.4 of the BLT library.  It is an extension to 
  233. Tk toolkit (it requires no patching of the Tcl or Tk libraries).  
  234.  
  235. This library works with the following releases of Tcl/Tk ONLY.
  236.  
  237.     Tcl 7.3 / Tk 3.6
  238.     Tcl 7.2 / Tk 3.5
  239.     Tcl 7.1 / Tk 3.4
  240.     Tcl 7.0 / Tk 3.3
  241.  
  242. The BLT toolkit contains the following widgets/commands:
  243.  
  244. 1) Drag-n-drop command: blt_drag&drop
  245.     Updated version of Michael McLennan's drag and drop command
  246.     (it's still maintained by Michael). 
  247.  
  248. 2) Hypertext widget: blt_htext
  249.     Allows text and Tk widgets to combined in a single scroll-able 
  250.     window.
  251.  
  252. 3) Busy window: blt_busy
  253.     For handling user-interaction when the application is "busy".
  254.     Manages an invisible "busy" window which prevents further 
  255.     user device (keyboard, mouse, button, etc.) interactions.
  256.     Also provides a different cursor which supersedes application
  257.     cursors.
  258.  
  259. 4) Bitmap command: blt_bitmap
  260.     Lets you read and write bitmaps from Tcl. Can define X bitmaps  
  261.     and create bitmaps from text strings.  Other options query any 
  262.         loaded X bitmap.
  263.  
  264. 5) Background "exec" command: blt_bgexec
  265.     Like "exec ... &", but collects the output of the detached 
  266.     UNIX subprocesses and sets a Tcl variable upon their completion.
  267.     Can be used with "tkwait variable" to handle application's 
  268.     expose events, etc. while waiting for subprocesses to finish.  
  269.  
  270. 6) Table geometry manager: blt_table
  271.     Specify window placements as table row,column positions. Also
  272.     has many options for placing constraints on window resizes.
  273.  
  274. 7) Barchart widget: blt_barchart
  275.     
  276. 8) XY graph widget: blt_graph
  277.  
  278. 9) Window option command: blt_win
  279.     Lets you raise, lower, map, or, unmap any window.  
  280.  
  281. 10) Watch commands: blt_watch
  282.     Lets you specify Tcl procedures to be run before and/or
  283.     after every Tcl command.  May be used for logging,
  284.     tracing, profiling, or debugging or Tcl code.
  285.  
  286. 11) Simple command trace: blt_debug
  287.     Simply prints out each Tcl command before it's executed.  
  288.  
  289. 12) Cutbuffer and bell commands: blt_cutbuffer, blt_bell
  290.     The commands are derived from the "bellcut" extensions and are 
  291.     provided as a convenience.  Credit should go to the author(s) 
  292.     (I can't remember who they are. Sorry) for this work.
  293.  
  294. ---------
  295.  
  296. Changes since BLT-1.3:
  297.  
  298. 1. Axis not re-scaling when changing log/linear scale.
  299.  
  300. 2. New command: "blt_watch" arranges for Tcl procedures to be 
  301.    called before and/or after the execution of every Tcl command. 
  302.    This command may be used in the logging, profiling, or tracing of 
  303.    Tcl code.
  304.  
  305. 3. Bug fixes:  See the file "ChangeLog" for details.  Thanks to all 
  306.    those who've sent me their reports and fixes.  
  307.  
  308. ---------
  309.  
  310. Changes since BLT-1.2:
  311.  
  312. 1. Fixed manual scaling bug (seen in ./demos/graph2)
  313.  
  314. 2. New feature: C interface to reset "blt_graph" element data.
  315.  
  316. 3. Bug fixes:  See the file "ChangeLog" for details.  Again, thanks 
  317.    to all those who've sent me reports.  
  318.  
  319. ---------
  320.  
  321. Changes since BLT-1.1:
  322.  
  323. 1. Fixed bug (coredump) in "blt_bgexec" command introduced 
  324.    last release.
  325.  
  326. 2. Fixed bug (error) in "blt_graph" and "blt_barchart" commands 
  327.    introduced in last release.  Bug doesn't allow axis -min, -max options 
  328.    to be reset to autoscale.
  329.  
  330. 3. Fixed bug in Kosherdill installation.
  331.  
  332. 4. New feature in "blt_graph" and "blt_barchart".
  333.    Added alternate x and y axes (x2, y2).  
  334.    Moved axis title options to their respective axis commands
  335.     .graph configure -xtitle "X Axis Title"
  336.    becomes
  337.     .graph xaxis configure -title "X Axis Title"
  338.  
  339. ---------
  340.  
  341. Changes since BLT-1.0:
  342.  
  343. 1. Many changes to configuration and install files.  Hopefully this
  344.    is an improvement.
  345.  
  346. 2. New options in "blt_graph" to detect closest point and highlight
  347.    single element data points.
  348.  
  349. 3. New option in "blt_bitmap" command lets you create bitmaps of rotated 
  350.    text strings.
  351.  
  352. 4. Restructured BLT library to facilitate loading as a shared object.
  353.  
  354. 5. Lots of bug fixes:  See the file "ChangeLog" for details.  Again, thanks 
  355.    to all those who've sent me reports.  
  356.  
  357. ---------
  358.  
  359. Changes since BLT-1.0b2:
  360.  
  361. 1. First BLT application.  
  362.                 Kosher Dill
  363.         ( KOmprehensive Storage HandlER / Disk ILLustrator )
  364.  
  365.        ---------------------------------------------------------------
  366.           Copyright (c) 1993  AT&T Bell Laboratories
  367.         Michael J. McLennan (michael.mclennan@att.com)
  368.        ---------------------------------------------------------------
  369.  
  370.        Kosher Dill is a simple utility for managing disk usage.  It
  371.        provides a graphical representation of the system "du" command,
  372.        along with drag&drop facilities for exploring, compressing
  373.        and removing files.
  374.  
  375.    It can be found in the new "blt-1.0/applications" directory.
  376.  
  377. 2. Drag-and-drop facility "blt_drag&drop".  Michael McLennan has updated
  378.    and added his drag-and-drop command.  
  379.  
  380. 3. Shared library target (for supported systems):  I've been able to test
  381.    this only on SunOS 4.x, SunOS 5.x, and HP-UX 9.01 systems.
  382.  
  383. 4. Add -updatevar flag to "blt_bgexec":  You can now get partial updates
  384.    of output as the program is running.  See the script "demos/bgexec".
  385.  
  386. 5. Library directory: This directory contains the drag-n-drop protocols
  387.    and the PostScript prolog for graph and barchart.  The path can be
  388.    set in the following ways:
  389.     
  390.     - compiled into the library.
  391.     - set by the environment variable "BLT_LIBRARY"
  392.     - set by the Tcl variable "blt_library"
  393.  
  394. 6. Lots of bug fixes:  See the file "ChangeLog" for details.  Thanks to 
  395.    all those who've sent me reports.  I really appreciate it.  
  396.  
  397. ---------
  398.  
  399. How to get and test BLT:
  400.  
  401. The following describes how to get and install the BLT library.
  402.  
  403. 0. FTP the distribution from harbor.ecn.purdue.edu
  404.  
  405.     ftp harbor.ecn.purdue.edu
  406.     cd pub/tcl/extensions
  407.     binary 
  408.     get BLT-1.4.tar.Z
  409.     quit
  410.  
  411. 1. Uncompress and untar the distribution file.  
  412.  
  413.     zcat BLT-1.4.tar.Z | tar -xvf - 
  414.  
  415.  
  416.    This will create a directory "blt-1.4" with the following 
  417.    subdirectories:
  418.     
  419.                         blt-1.4
  420.          ______________|_________________
  421.              |          |       |      |    |
  422.         applications  demos  library  man  src
  423.                                             |
  424.                                           shared
  425.  
  426. 2. Run ./configure
  427.  
  428.    Go into the "blt-1.4" directory 
  429.  
  430.     cd blt-1.4
  431.  
  432.    and run the auto-configuration script "./configure"
  433.  
  434.     ./configure 
  435.  
  436.    * If you want to use gcc, it's "./configure -with-gcc"
  437.  
  438.     ./configure -with-gcc
  439.  
  440.    * By default, the demo program, libBLT.a, the library files, and
  441.      manual pages will be installed in "/usr/local/blt".  You can 
  442.      change this by giving the -prefix option to ./configure.
  443.  
  444.     ./configure -prefix=/depot/stuff/blt
  445.     
  446.   You may be queried for the location of the Tcl and Tk libraries, if
  447.   "configure" can't find them in the standard locations.
  448.  
  449.   The configure script creates an include file "src/bltConfig.h".
  450.   It will also generate new Makefiles from their respective templates 
  451.   (Makefile.in).
  452.  
  453.     Makefile.in             ==> Makefile
  454.     src/Makefile.in            ==> src/Makefile
  455.     src/shared/Makefile.in    ==> src/shared/Makefile
  456.     man/Makefile.in        ==> man/Makefile
  457.     library/Makefile.in    ==> library/Makefile
  458.  
  459.   If "configure" can't find something (e.g. it can't find the X libraries),
  460.   edit the file "config.status" and run it.
  461.  
  462.     ./config.status
  463.  
  464.   Otherwise, you'll have to edit the Makefiles files by hand.
  465.  
  466.  
  467. 3. Compile the demonstation program "blt_wish".
  468.  
  469.     make 
  470.  
  471.  
  472. 4. Test by running the demos. 
  473.  
  474.    Go into the demos directory 
  475.     
  476.     cd demos
  477.  
  478.    and run the test scripts.
  479.     
  480.     ./graph
  481.  
  482.    If your system doesn't support "#!" in shell scripts, then it's
  483.  
  484.     ../blt_wish -f ./graph
  485.  
  486.  
  487. 5. Installing BLT
  488.  
  489.    The following directories will be created when BLT is installed.  
  490.    By default, the top directory is /usr/local/blt.  
  491.  
  492.        _____________|__________
  493.        |      |        |      |  
  494.       bin    lib     library man
  495.      
  496.    You can change the top directory by supplying the -prefix option to
  497.    ./configure.
  498.  
  499.    * If you don't install BLT, you will need to set the BLT_LIBRARY
  500.      environment variable or the Tcl variable "blt_library" in your
  501.      scripts.  Otherwise, you may not be able generate PostScript 
  502.      output for graphs and barcharts, or use the drag&drop facility 
  503.      properly.
  504.  
  505.  
  506. 6. BLT Applications
  507.  
  508.    In the "blt-1.4/applications" directory, there is the first 
  509.    application called "kosherdill".  It has its own README and
  510.    configure script.  
  511.  
  512. 7. Creating a shared library.
  513.  
  514.    This is currently available (and tested) on the following 
  515.    systems:
  516.  
  517.     SunOS 4.x
  518.     SunOS 5.x
  519.     HP-UX 9.01
  520.  
  521.    From the "blt-1.4" directory:
  522.  
  523.     make sharedlib
  524.  
  525.    This will create a shared library in the directory src/shared.
  526.  
  527.  
  528. 8. Adding BLT to your program.
  529.  
  530.    Add the following lines to your program's Tcl_AppInit routine 
  531.  
  532.     if (Blt_Init(interp) != TCL_OK) {
  533.         return TCL_ERROR;
  534.          }
  535.  
  536.    Link with libBLT.a
  537.  
  538.    and that's all there's to it.
  539.  
  540. 9. Send bugs reports, correspondence, etc. to
  541.  
  542.        george.howlett@att.com
  543.  
  544.  
  545.  
  546. %%
  547. global endOfText
  548. set endOfText [expr $blt_htext(line)-1 ]
  549.  
  550. global updateInterval count graph
  551. global Red Green Blue
  552. set updateInterval 2000
  553. set count 0
  554. set Red bb
  555. set Green 00
  556. set Blue 33
  557.  
  558. option add *Blt_barchart.title "Bar Chart" 
  559. option add *Blt_barchart.xTitle "X"
  560. option add *Blt_barchart.yTitle "Y"
  561. option add *Blt_barchart.y2Title "Y"
  562. option add *Blt_barchart.ySubTicks 0
  563. option add *Blt_barchart.xTicks 0
  564. option add *Blt_barchart.legendMapped false
  565. option add *Blt_barchart.AxisFont *-Courier-Bold-R-Normal-*-80-* 
  566. option add *Blt_barchart.y2Mapped true
  567.  
  568. blt_barchart $blt_htext(widget).b 
  569.  
  570. $blt_htext(widget) append $blt_htext(widget).b \
  571.         -relwidth 1.0 -relheight 0.5 -fill both
  572. set graph $blt_htext(widget).b
  573.  
  574. proc AnimateBarchart {  } {
  575.     global updateInterval
  576.     global count graph Red Blue Green
  577.     
  578.     if { [info commands $graph] != $graph } {
  579.         return
  580.     }   
  581.     incr count
  582.     if { $count > 16 } {
  583.         $graph element delete [lindex [$graph element show] 0]
  584.     }
  585.     set color [format "%x" [expr $count%16]]
  586.     set Green ${color}${color}
  587.     $graph element create $count -data { $count sin($count*0.1)} \
  588.         -fg #${Red}${Green}${Blue} -bg brown -mapy both
  589.     after $updateInterval AnimateBarchart
  590. }
  591. AnimateBarchart
  592.  
  593. %%
  594.  
  595.         Press %%
  596. button $blt_htext(widget).quit -command { destroy . } -text {Quit} -bg pink
  597. $blt_htext(widget) append quit
  598. %% to remove the window.
  599.  
  600.