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 [http://sourceforge.net/projects/tkcon] You can obtain the current CVS working files by executing cvs -d:pserver:anonymous@cvs.tkcon.sourceforge.net:/cvsroot/tkcon login just hit enter at the password prompt cvs -d:pserver:anonymous@cvs.tkcon.sourceforge.net:/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 [http://sourceforge.net/projects/tkcon/]. ---- '''History''' Tkinspect [ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/tkinspect-5.1.6.tar.gz] 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] [http://www.schooner.com/~loverso/tcl-tk/] 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 [ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/tkinspect-5.1.6p3.patch.tar.gz]. [Tako Schotanus] wrote a patch for TkInspect so it worked with incr Tcl [http://huizen.dds.nl/%7Equintess/]. [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:John@LoVerso.Southborough.MA.US (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:slshen@lbl.gov (Sam Shen) mailto:sls@aero.org (Sam Shen) mailto:ei9gl@indigo.ei (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. 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. I added some code that detects which version of Tk it is running under, so it reverts to the old frames if the panedwindow widget is not available. These were created from modified CVS files on June 23. 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 $self.sb -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 "$self.sb set" -selectmode single \ -xscroll "$self.sb2 set" ;# links horizontal scrollbar to the listbox bind $self.list <1> "$self click %x %y; continue" The changed files are available at: tkinspect.tcl [http://www.psnw.com/~alcald/tkinspect.tcl] lists.tcl [http://www.psnw.com/~alcald/lists.tcl] [Alex Caldwell] [[ [Category Application] | [Category Debugging] ]]