Version 28 of Tkinspect

Updated 2003-06-21 12:10:41

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 http://prdownloads.sf.net/tkcon

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 http://mini.net/sdarchive/tkinspect.kit (as well as at the above sf.net download page).

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


History

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)
 Where: http://tkcon.sf.net/ 
        http://prdownloads.sf.net/tkcon/tkinspect-5.1.6p10.kit
        http://tkcon.sourceforge.net/tkinspect/
 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)
 Where: http://www.schooner.com/%7Eloverso/tcl-tk/ 
 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)
 Where: ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/tkinspect-5.1.6.tar.gz 
        http://huizen.dds.nl/%7Equintess/pub/tkinspect_itcl.patch.tar.gz 
        ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/tkinspect-5.1.6p3.patch.tar.gz 
 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)
        mailto:[email protected] (Paul Healy)

Discussion about generalising 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


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.


[ Category Application | Category Debugging ]