Tkinspect is a tool to permit one to inspect the contents of a separate running Tk application. It has views for the variables, arrays, procedures and other objects in the inspectee and communicates using the Tk send command.

The application was originally writted by Sam Shen and is now maintained as a module of the tkcon SourceForge project [L1 ] You can obtain the current CVS working files by executing

  cvs -d:pserver:[email protected]:/cvsroot/tkcon login
  just hit enter at the password prompt
  cvs -d:pserver:[email protected]:/cvsroot/tkcon co tkinspect

or you can download tar and zip files from the latest file releases from

The current file release (June 2003) is 5.1.6p10 which incorporates support for use under windows (using dde or comm instead of send ), support for incr Tcl 3.2 and a number of bug fixes.

Some people have found having to get tkinspect via cvs to be more difficult than they prefer. For these people as well as for those who are used to using tclkit, a Starkit version of tkinspect is available at (as well as at the above download page).

Bug reports, patches and feature requests should all be submitted to the tkcon project tracker please [L2 ].


Tkinspect [L3 ] has quite a history in the Tcl/Tk environment. Created by Sam Shen, tkinspect provides the ability to examine and modify the procs and variables of any Tcl/Tk application with a working "send" command.

Later, Sam moved on and a few other people have since made modifications. John Robert LoVerso [L4 ] modified tkinspect so that it used comm instead of send. This allowed one to run tkinspect under any operating system which supports sockets.

Paul Healy then wrote a patch so that tkinspect knows about Tcl 8 namespaces [L5 ].

Tako Schotanus wrote a patch for TkInspect so it worked with incr Tcl [L6 ].

Pat Thoyts integrated the above patches and is now maintaining the code at SourceForge.

Mike Clarkson overhauled its GUI and included it in TixApps.

Current version of Tkinspect:

What: tkinspect (Thoyts)
Description: Allow browsing/inspection of running Tk applications. Based on Tkinspect 5.1.6, with patches from various people over the years so that incr tcl is supported, comm communications is supported, etc.
This version works with Tk 8.3 or better.
Note that a Tclkit based Scripted document of tkinspect is available - see the prdownloads url above.
Currently considered version 5.1.6p10
Updated: 21/Jun/2003
Contact: See the web site

Older versions of Tkinspect

What: tkinspect (LoVerso)
Description: Modified version of tkinspect so that it uses comm. This allows tkinspect to run under Windows. tkinspect-lite contains just the pieces of tkinspect-full that differ from the authority version of tkinspect.
Updated: 12/1998
Contact: mailto:[email protected] (John Robert LoVerso)

What: tkinspect (Shen)
Description: Allow browsing/inspection of running Tk applications. This version works with Tk 4.0b4 or better. Paul Healy has written a patch to v5.1.6 so that it is compatible with Tk 8, with introspection for Tcl 8 namespaces.
Updated: 12/1997
Contact: mailto:[email protected] (Sam Shen)
mailto:[email protected] (Sam Shen)

Discussion about generalizing the send command moved to Transport independent send

The Tcl Dev Kit provides an enhanced version of TkInspect.

Perhaps some of these enhancements might get submitted back the the tkinspect project? (hint hint) -PT

JH - the TDK Inspector was originally an enhanced TkInspect, but we completely rewrote it. No more home-brew object system, different widgets used (ttk required), etc. While they provide similar features, any enhancements can't be simply pruned from the underlying code.

TkInspect: a simple example. [PT]

Let's fire up wish and do something simple. Now Windows Tk doesn't have a send command, so we need to help it along a little by using a substitute. Either dde, winsend or comm can help here - Tcl provides dde by default.

  package require dde
  dde servername TestApp

  proc main {} {
     set dlg [toplevel .dlg]
     set but [button ${dlg}.b -text "OK" -command [list destroy $dlg]]
     pack $but -side bottom
     tkwait window .dlg

Now we have this evaluated in our shell, let's fire up tkinspect. The starkit is a handy way to get this. If you set up some file associations under Windows you can launch it very simply:

  assoc .kit=TclkitFile
  ftype TclkitFile=tclkit.exe %1 %*

By using winsend or dde, tkinspect can automatically find your other Tk applications. Under X Windows it'll do this anyway. Go to the File->Select interpreter (send) menu item and select TestApp. You are now connected to your Test App interpreter.

The default view has Namespaces, Procs and Globals views. In Namespaces, select the :: item at the top. The lower window should now be filled with lots of tcl's predefined variables and their values. If you scroll down a bit you will find a list of procedure defined in the global namespace.

Now in the Procs view, select your main procedure. You should see the source as above. Hmm. Let's edit this a bit. Replace the text in the window with this

 proc main {} {
   set dlg [toplevel .dlg]
   set but [button ${dlg}.b -text "OK" -command [list destroy $dlg]]
   set can [button ${dlg}.c -text "Cancel" -command [list destroy $dlg]]
   pack $but $can -side left
   tkwait window .dlg

Now press the Send Value button at the top right, near the menu bar. It should say 'Value sent' in the status bar. As we don't want to bother switching windows, type 'main' in the Command entry and press the Send Command. Your other application should now pop up a dialog with OK and Cancel buttons. If you close this and enter 'info body main' in your wish shell, you'll see the body has indeed been changed.

While we are in the TestApp - lets create a variable. Enter 'set A 0' and then switch back to tkinspect.

The Globals view in tkinspect displays the global variables defined in the remote interpreter. You'll notice that your variable doesn't appear yet. Right click and select Update this list or select the Globals->Update this list menu item and it should appear. If you select this now, the value window will display the value as a set statement.

This is fine but it's much more interesting to monitor for changes in our variables. For this we can set a trace by selecting the variable name and using 'Globals->Trace variable'. This will pop up a dialog labelled 'Trace Scalar:TestApp/A' with the current value displayed in the dialog. If we now change the variable in the TestApp, the new value is printed below. The same is true of array variables.

GUI enhancement for Tkinspect - using panedwindow for lists instead of frame

I added a few changes to the files tkinspect.tcl and lists.tcl that allow Tkinspect to use the new pane widget from Tk8.4 instead of frames. It also adds a horizontal scrollbar to the bottom of each listbox. This allows you to resize the width of the lists in Tkinspect. This makes it much more pleasant to use when you have a bunch of very long widget names or a long variable names that don't fit in the width of the normal list boxes in Tkinspect,which are fixed in width and become very narrow if you have several lists displayed. I added some code that detects which version of Tk it is running under, so it reverts to the old frame widget if the panedwindow widget is not available. These were created from modified CVS files on June 21 2003. The changes look like this: in the file tkinspect.tcl in the method:create proc I added:

        button $f.send_value -text "Send Value" \
            -command "$self.value send_value"
        pack $f.send_command $f.send_value -side left

     # the lines above are not changed
     # lines below changed to use a panedwindow instead of a frame
      if {[llength [split $tk_patchLevel "."]] == 3 
        && [lindex [split $tk_patchLevel "."] 0] >= 8 
        &&    [lindex [split $tk_patchLevel "."] 1] >= 4} {
        pack [panedwindow $self.lists -showhandle 1] -side top -fill both
      } else { 
         pack [frame $self.lists -bd 0] -side top -fill both
     # end of change to use panedwindow instead of frame

        value $self.value -main $self
        pack $self.value -side top -fill both -expand 1
        foreach list_class $tkinspect(default_lists) {
            $self add_list $list_class
            set slot(${list_class}_is_on) 1

In the file lists.tcl I added these changes in the method:create proc to add a horizontal scrollbar to the listboxes:

    scrollbar $ -command "$self.list yview" -relief sunken -bd 1
    # adds a horizontal scrollbar 
    scrollbar $self.sb2 -command "$self.list xview" -relief sunken -bd 1 -orient horizontal
        listbox $self.list -relief sunken -exportselection 0 \
            -yscroll "$ set" -selectmode single \
        -xscroll "$self.sb2 set" ;# links horizontal scrollbar to the listbox
        bind $self.list <1> "$self click %x %y; continue"

Problem - I noticed the panes don't seem to be resizable by dragging the handles for some reason. I must have some thing not quite right.

The changed files are available at:

tkinspect.tcl [L7 ]

lists.tcl [L8 ]

Alex Caldwell

PT 05-Jul-2003: These enhancements have been merged into the Tkinspect CVS tree.

dzach 10-Sep-2005: I kept getting these can't modify -container option after widget is created errors whenever I tried to send a value containing a -container option. So here is a change to the windows_list.tcl file that adds a send filter for the -container option:

At line 46 insert:

                $slot(menu) add checkbutton \
                -variable [object_slotname filter_window_container] \
                        -label "Filter Window -container Options"

and then just before the return at the end:

        if $slot(filter_window_container) {
                regsub -all "(\n)\[ \t\]*-container\[ \t\]+\[^ \\\n\]*\n?" $value \
                "\\1" value

dzach 16-Sep-2005: It may have been documented elswhere (I cannot find any reference though) but it is useful to know that there is a way to customize the default filters for Procs and Globals (and other lists too). To do it:

   * Open file defaults.tcl in the tkinspect directory
   * Edit/Add the following for filtering Procs
    option add *Procs_list.patterns {
        # add more filters here...
   * Edit/Add the following for filtering Globals
    option add *Globals_list.patterns {
        # add more filters here...
   * Add other options as needed

DeClarke - 2014-01-12 19:41:34

I've been retired a few years and am now doing a bit of Tcl/Tk hacking just for fun and brain-fitness. Tkinspect was my favourite debug/devel tool back in the day, so I'd like to get it working in my new environment. Unfortunately (or not) that environment is OSX 10.6.8 (with X11 of course). I have AS Tcl kit installed with various extensions, all working fine; but Tkinspect for some reason cannot see any other interps. I'm trying to recall a teasing memory fragment about X11 and some kind of access control/config option that permitted dialogue between windows on the same desktop... I'll keep googling and try to puzzle it out, but if anyone can hand me a shortcut, my aging brain could do with a bit of a nudge.