Recent Changes - Search:



Getting BLT 2.5

Blt has been massively updated for use with Wize to support Tcl/Tk 8.5. The version has been bumped to Blt-2.5. This can be downloaded from:


or from:

BLT in Wize

The BLT extension adds several significant features to Tk, including:

  • TreeView - a tree/table widget.
  • Tabset - a notetab widget with tearoff tabs.
  • Graphs - various graph widgets.
  • Vectors - arrays of double floats
  • Trees - a tree structure
  • Tile - widget background image tile.
  • Winop - window and image gradients and ops.
  • Blt Tile - Shaped buttons.

The version of BLT used in Wize has been extensively modified to fix problems, fill in missing functionality, and enhancing features.


Graphs in should work unchanged from version 2.4 of BLT. The only possible exception is for graphs using vectors. Vectors are now created in the current namespace (see below).


BLT vectors provide access to an array of doubles.

Several changes have been made to vector:

  • Vectors now uses current namespace on creation.
  • Add 2d matrix/array indexes (to work with tktable).
  • Add a new shift N expression for accessing a shifted vector.
  • Vector functions assume current vector if given no arg in expr.
  • Add a vector configure subcommand to change default options.
  • Honor setting -command {} to not create a command.
  • Add the op subcommand for accessing non-command vectors.

Matrix Vectors

The matrix feature supports 2d indexing of arrays. There are 2 ways to create a matrix: create a vector with dimensions like aVec(10,3) or use the subcommand matrix numcols. Either way results in a 2d matrix view into 1d data.

Matrix provides operations for columns such as delete, and move. It also supports matrix multiply and transpose. Moreover, a matrix vector can be used with Tktable, eg:

  vector create aVec(10,3)
  pack [Table new .t -variable aVec -rows 10 -cols 3]
  vector op seq aVec 1 end;      # Now fill it!

It is also possible to display a vector in a TreeView. This lets you take advantage of autosizing columns and enhanced display options.

(:showex div=tosamp:)

The first 2 screenshots show Tk Table being used to display a vector and the 3rd TreeView with autoloading cell data. The main difference is that TreeView autosizes columns and the drop shadowing is used in column 0:

Here is the source:

# Demo comparing display of a vector in Tktable and TreeView.

proc valid {vec cell str}  {
    # Validate that a user edit is actually entering a double.
    set rc 0
    if {[set s [string trim $str]] == {} ||
    [string match - $s] || [string is double $s]} { set rc 1; }
    if {!$rc} { bell }
    return $rc

proc FillTableCell {idx args} {
    # Return vector value for Table cell.
    variable v2
    if {[string first -1 $idx]>=0} {
        if {[string equal -1,-1 $idx]} {
            return R\\C
        if {[string match -1,* $idx]} {
            return [string range $idx 3 end]
        if {[string match *,-1 $idx]} {
            return [string range $idx 0 end-3]
    return $v2($idx)

proc RowTag {r} {
    if {$r%2} { return altrow }

proc VecVarTable {} {
    # Display vector in a Tktable.
    set rows 10000
    set cols 20
    vector create v0([expr {$cols*$rows}])
    vector op matrix numcols v0 $cols
    vector op seq v0 1 end

    Toplevel new .v
    wm title .v "Vector Variable Table: v0"
    set t .v.t
    pack [Scrollbar new -command "$t xview" -orient horizontal] -side bottom -fill x
    pack [Scrollbar new -command "$t yview"] -side right -fill y
    Table new $t -rowtagcommand {RowTag}  -anchor e -variable ::v0 \
    -bg White -autoclear 1  \
    -yscrollcommand " set" -xscrollcommand " set"
    pack $t  -side right -fill both -expand y
    Table tag conf $t altrow -bg LightBlue
    Table tag conf $t title -anchor c -relief raised -bd 1 -bg \
LightGrey -fg Black -font {Helvetica -12 bold}

proc VecTable {} {
    # Display vector in a Tktable.
    wm title . "Vector Table: v1"
    set rows 10000
    set cols 20
    vector create v1([expr {$cols*$rows}])
    vector op matrix numcols v1 $cols
    vector op seq v1 1 end
    set t .t
    pack [Scrollbar new .sh -command "$t xview" -orient horizontal] -side bottom -fill x
    pack [Scrollbar new .sv -command "$t yview"] -side right -fill y
    Table new $t -anchor e -colorigin -1 -roworigin -1 \
        -bg White -command {FillTableCell %C} -autoclear 1 \
       -validate 1 -validatecommand {valid ::v1 %C %S} \
       -usecommand 1 -cols $cols -rows $rows \
       -yscrollcommand ".sv set" -xscrollcommand ".sh set" \
       -titlerows 1 -titlecols 1
     pack $t  -side right -fill both -expand y
     Table tag conf $t altcol -bg LightBlue
     for {set i 0} {$i<$cols} { incr i 2} {
        Table tag coltag $t altcol $i
    Table tag conf $t title -anchor c -relief raised -bd 1 \
-bg LightGrey -fg Black -font {Helvetica -12 bold}

proc FillTreeCell {c r args} {
    # Return vector value for TreeView cell.
    variable v2
    set val $v2($r,$c)
    if {0 && [string first 4 $val]>0} {
        return [list @img $val]
    return $val

proc VecTree {} {
    # Display vector in a TreeView.
    set rows 10000
    set cols 20
    vector create v2([expr {$cols*$rows}])
    vector op matrix numcols v2 $cols
    vector op seq v2 1 end
    Toplevel new .x
    wm title .x "Vector TreeView: v2"
    set t .x.t
    pack [Scrollbar new -command "$t xview" -orient horizontal] -side bottom -fill x
    pack [Scrollbar new -command "$t yview"] -side right -fill y
    TreeView new $t -bg White  -width 700 \
        -yscrollcommand " set" -xscrollcommand " set"
    pack $t -side right -fill both -expand y

    for {set i 0} {$i<$cols} { incr i} {
        TreeView column insert $t end c$i -justify right -title \
        $i -bd 1 -relief raised -fillcmd [list FillTreeCell $i]
    set cf [lindex [TreeView column names $t] 0]
    TreeView style create textbox $t alt -bg LightBlue
    TreeView style create textbox $t trow -bg DarkGray -fg White\
   -shadow Black -priority 2 -font [TreeView cget $t -titlefont]
    TreeView column conf $t $cf -style trow -title R\\C
    TreeView column conf $t $cf -relief raised -bd  1
    TreeView conf $t -altstyle alt -hideicons 1 -flat 1 -underline 1
    for {set r 0} {$r<$rows} { incr r} {
        $t insert end $r

proc Main {} {

eval Main

See the matrix section of the vector manpage for more details.


BLT provides a tree data structure. Trees are used implicitly by TreeView. Explicit use of a tree can allow multiple widgets to display the same (or a subset of the same) tree data.

The only real change to tree in Wize is the addition of an op sub-command for providing non-command access.

Summary of Enhancements

Wize started with BLT2.4z ( and applied all known fixes. Then the following was changed:

  • NEW: Extend tree to be more generally useful.
  • Internalize old configure to work under Tcl 8.5
  • Complete missing/broken parts of treeview and tabset widgets.
  • Fix many TreeView display inconsistencies.
  • NEW: TreeView style create ie. $t style create textbox ...
  • NEW: add 2 styles: windowbox and barbox.
  • NEW: Numerous TreeView options including: -altstyle -underline.
  • NEW: Added numerous TreeView subcommands.
  • NEW: Support for displaying subtrees (if using -tree).
  • Integrate font/image changes to propagate to/from BLT widgets.
  • Improve TreeView display performance with large trees.
  • Change/extend TreeView editing to use Tk widgets or windowbox.
  • Fixes and enhancements for Vector (see below)
  • Add op object subcommand to tree and vector.
  • Rename BLTs table to blttable to avoid tktable collision.
  • Extend Tk widgets to use BLT's tile facility.
  • Add stubs for vector and tree functions.
  • Add Winop subcommands: transparent and merge.
Edit - History - Print - Recent Changes - Search
Page last modified on September 15, 2011, at 01:00 PM