Purpose: to describe the tkcon application and the special features that make it a worth the moments it takes to download. ---- TkCon provides a console for interacting with [Tcl]. This console has an input history, the ability to help loading packages, ability to attach to running [Tk] applications (if on a system which supports Tk's [send] command), === What: TkCon Where: http://tkcon.sourceforge.net/ http://tkcon.sourceforge.net/docs/index.html Description: A Tcl/Tk source standard console. It not only is a replacement for the one that comes with Tk on Windows and Macintosh, but can also be used under Unix. Provides command history, path/proc/variable name expansion, multiple interpreter consoles, captures stdout and stderr, character and proc highlighting, history searching, copy/paste between consoles, communicate with other tk interpreters, supports dynamically loadable extensions, electric character and proc highlighting. Latest version supports attaching to itcl/Tcl 8 namespaces. Regular updates occur - check pack on the WWW page for announcements. Requires Tcl/Tk 8.0+ . Currently version 2.5 There is also a megawidget console based on tkcon. Updated: 2009-02-26 Contact: jeff at hobbs org === ---- * Using [TkCon as an application console]. * Using [Tkcon as an IDE shell]. ---- [stevel]: tkcon packaged as a [starkit] can be found at http://www.tcl.tk/starkits/tkcon.kit). The tkcon "Help/Retrieve latest version" option will update the starkit with the latest CVS version of tkcon.tcl. [LV] Steve, the code for retrieve latest version would be useful to turn into a proc that became part of tclkit's std environment, so that all starkits might do that. Or at least, all the ones at sf.net... This application is also part of the [ActiveTcl] Batteries Included distribution. Tkcon is in the bin directory, which you can find with ''[[info nameofexecutable]]'' and ''[[file dirname]]''. It is named ''tkcon.tcl'' on Windows and ''tkcon'' (without ''.tcl'') on Unix. ---- Unofficial standalone TkCon (with [Tclkit] 8.5.8) : * For [Windows] : http://www.kroc.tk/fichiers/tkcon.exe <-- [starpack] * For [Mac OS X] : http://www.kroc.tk/fichiers/TkCon.zip <-- script in TkCon.app * For [Linux] : http://www.kroc.tk/fichiers/tkcon.gz <-- [starpack] ---- [SYStems] it's no longer included in the last ActiveTcl release for Tcl 8.5 . Why is it so? [lv] This is part of the [ActiveTcl] team's ''slimming of the download'' effort. Once ActiveTcl 8.5 is installed, make use of [teacup] to install tkcon (and lots of useful Tcl extensions, etc.). ---- This application is also included in [WinTclTk]. A single-file Tkcon executable for 32-bit Microsoft Windows Operating Systems wrapped using TkWrap (part of [WinTclTk]) can be found at http://wintcltk.sourceforge.net/tkwrap.html ---- To get tkcon to work using only the main interpreter and the . toplevel, [Jeff Hobbs] writes: You need to pass with -exec "" on the command line (in ::argv) or add the following code before you source tkcon: ====== namespace eval ::tkcon {} # we want to have only the main interpreter set ::tkcon::OPT(exec) "" ====== ---- In a [comp.lang.tcl] posting, Glenn Jackman offers his personal '''tkcon.cfg''' source: ====== # tkcon.cfg tkcon font "Lucida Console" 10 set ::tkcon::OPT(rows) 40 # source $env(HOME)/tclshrc.tcl # hmmm, can't load procs in this config file. # ah: set ::tkcon::OPT(slaveeval) {source $env(HOME)/tclshrc.tcl} ====== [kpv] Here's my tkcon.cfg file as a more complicated example: ====== set ::tkcon::OPT(rows) 14 set ::tkcon::OPT(cols) 75 set ::tkcon::OPT(font) "Courier 12" set ::tkcon::OPT(history) 300 set ::tkcon::OPT(autoload) Tk set ::tkcon::OPT(calcmode) 1 set ::tkcon::OPT(maxlinelen) 500 set ::tkcon::OPT(slaveeval) { source c:/home/.wishrc package require Img wm protocol . WM_DELETE_WINDOW exit } set ::tkcon::OPT(maineval) { wm geom . +140+825 bind TkConsole [bind TkConsole <>] bind TkConsole [bind TkConsole <>] bind TkConsole [bind TkConsole <>] bind TkConsole [bind TkConsole <>] } ====== [hv] On my Linux Mint 11, I found the following font and color works best for me: ====== set ::tkcon::COLOR(bg) ivory set ::tkcon::OPT(font) "{Liberation Mono} 10" set ::tkcon::OPT(rows) 40 set ::tkcon::OPT(cols) 80 ====== ---- Outstanding questions relating to tkcon: ---- [NC] Is it possible to use tkcon as the default wish console? ---- [JH]: '''Debugging with tkcon''' I was asked: * [[could someone discuss how to debug with tkcon: explain idebug [http://tkcon.sourceforge.net/docs/idebug.html], observe [http://tkcon.sourceforge.net/docs/observe.html], "hot errors", and state introspection.]] ''idebug'' is a very simple "debugger" that is really more of an interactive introspection tool. You have to actively add the ''idebug break'' lines into your code. You can turn off idebug triggers globally (or by id). You can also add ''idebug trace'' calls which just show the call stack anytime they are hit. ''idebug'' was inspired by an earlier work done by Stephen Uhler (one of the former Tcl Sunlabs folks). When you stop at an idebug breakpoint, you can introspect or eval any code you want. There are shortcuts for most introspection, just type '?' to see them. ''observe'' is just a wrapper around [trace] that allows you to watch variable modifications or command invocations easily in tkcon. ''hot errors'' is the facility in tkcon that makes any error thrown to the toplevel tkcon command line a link. Clicking on the link will pop up the full error (with [errorInfo]) and, where possible, highlight procs. Green highlighted procs will pop up an edit window with that proc information, while blue highlighted procs will do the same, but highlight the error information it received from the stack trace. In this way, errors in your code that reach the global level become much easier to debug. Try this example in tkcon: ====== % proc foo {args} { set a b $args } % proc bar {} { foo a b c } % bar wrong # args: should be "set varName ?newValue?" ====== and click on the error. Simply by running in tkcon you can do all sorts of introspection and state modification. It has many other features, but now my fingers are tired ... [KPV] The way I do the bulk of my debugging with tkcon is by simply pasting in lines of code. I get to a quiescent state in the program, then ''walk'' the code by copying lines of my tcl code from the editor and pasting them into the console. [LV] most of my programs have much too much state, and interaction, for me to imagine myself being very successful working that way. [KPV] Most of my programs proceed in two stages: start up stage and then an event driven stage. To debug the first stage I just put in one or more ''return'' to get back to the console prompt, at which I can proceed as described above. The second stage is even easier--you're already at the command prompt. ---- [Victor Wagner] has expressed interest in running Tkcon on [MS-DOS]. ---- Here is some code for [Tkcon remote access over TCP sockets]. ---- [NEM]: A version of [RS]'s 'see' proc for viewing images inline in the [console], adapted for TkCon: ====== proc see image { set im [tkcon eval image create photo -file $image] tkcon console image create end -image $im tkcon console insert end \n } ====== An example showing the use: http://www.cs.nott.ac.uk/~nem/tkcon_see.png Also, [[tkcon eval package require [Img]]] will help a lot. ---- See also: [tkcon.cfg] and [Pasting commands into Tkcon] ---- [Arts and crafts of Tcl-Tk programming] <>Application|Debugging