Posted to tcl by daapp at Thu Jan 22 09:40:59 GMT 2009view raw
- package require Tk
- package require BLT
- namespace import blt::*
-
- # vector and stripchart are blt components.
- # if you have a vector v, you can update it in realtime with
- # v set $list
-
- # init the vectors to a fixed size.
-
- set Hz 400
-
- vector xvec($Hz) y1vec($Hz) y2vec($Hz)
-
- # fill xvec with 0 .. $Hz-1
-
- xvec seq 0 [expr {$Hz - 1}]
-
- stripchart .s1;# -height 2i -width 8i -bufferelements yes
-
- pack .s1 -fill both -expand true
-
- .s1 element create line1 -xdata xvec -ydata y1vec -symbol none
-
- # update $Hz values with random data once per second
-
-
- Blt_ZoomStack .s1
- Blt_Crosshairs .s1
- Blt_ActiveLegend .s1
- Blt_ClosestPoint .s1
-
-
- set i 0
- proc proc1sec {} {
-
- # this can be done more concisely with vector random,
- # but if you need to fill a vector from scalar calculations,
- # do it this way:
- global i y1list y2list
-
-
- if {$i < $::Hz} {
- lappend y1list [expr {rand() * 100}]
- incr i
- y1vec set $y1list
- after 1 proc1sec
- }
-
- }
-
- proc1sec
- focus -force .
-