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
32 source scripts/stipples.tcl
34 option add *graph.x.Title "X Axis Label"
35 option add *graph.y.Title "Y Axis Label"
36 option add *graph.title "A Simple Barchart"
37 option add *graph.x.Font { Times 10 }
38 option add *graph.Element.Relief raised
40 set visual [winfo screenvisual .]
41 if { $visual != "staticgray" && $visual != "grayscale" } {
42 option add *graph.LineMarker.color yellow
43 option add *graph.Element.Background white
44 option add *graph.Legend.activeForeground pink
45 option add *print.background yellow
46 option add *quit.background red
47 option add *graph.background palegreen
48 option add *graph.plotBackground lightblue
52 { This is an example of the barchart widget. The barchart has
53 many components; x and y axis, legend, crosshairs, elements, etc.
54 To create a postscript file "bar.ps", press the %%
56 button $w.print -text {Print} -command {
57 $graph postscript output bar.ps
64 set graph [barchart .htext.graph]
68 $graph xaxis configure \
71 $w append $graph -fill both -padx 4
76 button $w.quit -text quit -command exit
79 %% button when you've seen enough.%%
81 label $w.logo -bitmap BLT
82 $w append $w.logo -padx 20
86 set names { One Two Three Four Five Six Seven Eight }
87 if { $visual == "staticgray" || $visual == "grayscale" } {
88 set fgcolors { white white white white white white white white }
89 set bgcolors { black black black black black black black black }
91 set fgcolors { yellow orange red magenta purple blue cyan green }
92 set bgcolors { yellow4 orange4 red4 magenta4 purple4 blue4 cyan4 green4 }
95 set numColors [llength $names]
104 $graph element create sin -relief raised -bd 1 -x x -y y -barwidth $barWidth
105 table . .htext -fill both
110 Blt_Crosshairs $graph
111 Blt_ActiveLegend $graph
112 Blt_ClosestPoint $graph