4 # --------------------------------------------------------------------------
5 # Starting with Tcl 8.x, the BLT commands are stored in their own
6 # namespace called "blt". The idea is to prevent name clashes with
7 # Tcl commands and variables from other packages, such as a "table"
8 # command in two different packages.
10 # You can access the BLT commands in a couple of ways. You can prefix
11 # all the BLT commands with the namespace qualifier "blt::"
14 # blt::table . .g -resize both
16 # or you can import all the command into the global namespace.
18 # namespace import blt::*
20 # table . .g -resize both
22 # --------------------------------------------------------------------------
24 if { $tcl_version >= 8.0 } {
25 namespace import blt::*
26 namespace import -force blt::tile::*
29 source scripts/demo.tcl
31 proc random {{max 1.0} {min 0.0}} {
34 set randomSeed [expr (7141*$randomSeed+54773) % 259200]
35 set num [expr $randomSeed/259200.0*($max-$min)+$min]
43 source scripts/stipples.tcl
44 source scripts/patterns.tcl
46 option add *Barchart.title "A Simple Barchart"
47 option add *Barchart.relief raised
48 option add *Barchart.borderWidth 2
49 option add *Barchart.plotBackground white
50 option add *Barchart.baseline 57.299
52 option add *Element.borderWidth 2
53 option add *Element.Background white
54 option add *Element.Relief raised
56 option add *x.Title "X Axis"
57 option add *x.Font *Times-Medium-R*10*
58 option add *y.Title "Y Axis"
59 option add *LineMarker.Foreground yellow
61 set visual [winfo screenvisual .]
62 if { $visual != "staticgray" && $visual != "grayscale" } {
63 option add *print.background yellow
64 option add *quit.background red
65 option add *graph.background palegreen
69 { This is an example of the barchart widget. The barchart has
70 many components; x and y axis, legend, crosshairs, elements, etc.
71 To create a postscript file "bar.ps", press the %%
73 button $w.print -text {Print} -command {
74 $graph postscript output bar.ps
81 $graph xaxis configure -rotate 90 -stepsize 0
83 htext .footer -text { Hit the %%
84 set im [image create photo -file ./images/stopsign.gif]
85 button $htext(widget).quit -image $im -command { exit }
86 $htext(widget) append $htext(widget).quit -pady 2
87 %% button when you've seen enough. %%
88 label $htext(widget).logo -bitmap BLT
89 $htext(widget) append $htext(widget).logo
106 foreach { color stipple } $attributes {
107 $graph pen create pen$count -fg ${color}1 -bg ${color}4 -stipple $stipple
108 lappend styles [list pen$count $count $count]
115 y expr random(x)*90.0
116 w expr round(y/10.0)%$count
119 $graph element create data -label {} \
120 -xdata x -ydata y -weight w -styles $styles
123 0,0 .header -fill x \
124 1,0 .graph -fill both \
127 table configure . r0 r2 -resize none
132 Blt_Crosshairs $graph
133 Blt_ActiveLegend $graph
134 Blt_ClosestPoint $graph