Slicer3:GUI Experiments:TkTreeCtrl

From NAMIC Wiki
Revision as of 21:04, 5 August 2007 by Pieper (talk | contribs) (→‎Plans)
Jump to: navigation, search
Home < Slicer3:GUI Experiments:TkTreeCtrl

Background

TkTreeCtrl is a pretty amazing set of interface functionality for displaying trees where each row can be a multi-column list and/or a set of interface widgets. The interface is highly configurable (as shown in the demos) and very efficient. It is a cross-platform tcl extension.

As of late June 2007, TkTreeCtrl is built as part of KWWidgets and is exposed for use in Slicer3. Note that it does not yet have a C++ API so any use of TkTreeCtrl must be implemented in tcl (this code can be invoked from C++ using the Script() method on a KWWidget).

Running the Demo in Slicer3

First, download and unpack the package from TkTreeCtrl. Version 2.2.3 or later should work.

In Slicer3:

  • open the tcl console (Control-T or use the menu)
  • cd to the directory where you unpacked TkTreeCtrl
  • cd to the demos directory
  • type the following commands
proc console {args} {}
source demo.tcl
wm deiconify .
  • experiment and have fun!
    • note that the File menu includes options for viewing the source of each demo (note how brief and elegant each demo is!)
    • you can even watch the events as you interact with the tree demos
    • you can edit the configuration parameters of the trees on the fly and see the visual result

Plans

  • Test the widget
    • Example MRML tree (Steve) (see the ColorTree example described below)
    • Model Hierarchy display properties (Alex)
    • EMSegment (Brad)
    • QueryAtlas (Wendy)
  • Propose useful C++ API (all) for implementation by Sebastien and Yumin

Links

Note there is an HTML manpage with the source distribution that you can load into a browser to use as a reference.

Example

The simple example below is taken from [1] and can be pasted directly into the slicer3 tcl console:

catch "destroy .t"
toplevel .t
package require treectrl
treectrl .t.t
pack .t.t
.t.t column create
.t.t column configure 0 -text Items -expand yes -button no
.t.t element create el1 text
.t.t style create s1
.t.t style elements s1 el1
set itm [.t.t item create]
.t.t item style set $itm 0 s1
.t.t item text $itm 0 "Hello World"
.t.t item lastchild root $itm