Scripting tkoutline
Not logged in

Tkoutline can be interactively scripted. A command interpreter console can be summoned by hitting the <F2> key. Any valid Tcl/Tk command 1 can be executed in the console. In addition, any outline widget subcommands can be executed directly in the console. When the widget object command is omitted, the current outline is implied. For example, if the command "tree" is typed, then it will actually execute as a subcommand of the currently active outline.

I don't feel I'm being at all clear with the above explanation--I'm just going to jump ahead with some examples. Execute tkoutline, open a new outline and hit the <F2> key to open the console window. Then type (or copy and paste) the following examples into the console:

 # Retrieve the id of the current node
 set node getnode insert

# Insert some new nodes as children of that node set child1 tree insert $node 0 set child2 tree insert $node 1

# Hide the new children tree set $node expand 0

# Show them again tree set $node expand 1

# Set the text of the child nodes tree set $child1 title "I'm the first child of $node" tree set $child2 title "I'm the second child of $node"

# Hide the console console hide

A more advanced example - sorting nodes

Start a new outline (File, New), Hit F2 to get to the console and paste in the following commands:

 # Create some dummy nodes with numbers as their headline text
 foreach headline {5 9 4 3 8 2 0 7} {
    set n tree insert root 0
    tree set $n title $headline
 tree delete node1     ;# Delete the initial default node

# Helper function for sorting nodes alphabetically by node text proc nodeSortCmd {tree node1 node2} { return string compare [$tree set $node1 title $tree set $node2 title] }

# Sorts the children of the given node proc sortChildren {tree node} { set nodes lsort -command [list nodeSortCmd $tree $tree children $node] if {llength $nodes > 0} { eval $tree move $node 0 $nodes } } sortChildren tree root

Starting with version 0.93, tkoutline automatically sources the startup script ~/.tkoutlinerc. Editing the startup script can be done within tkoutline by selecting the Edit->Edit Startup Script menu pick.

Example modifications:

Also, tkoutline can be used as a library in other applications. For an example of this see TkGamePack (, an application where I use tkoutline as a game launcher for almost 90 Tcl/Tk games. See also for a screenshot and some discussion.