** Summary ** '''[http://tkcon.sourceforge.net/%|%tkcon]''' is a replacement for the standard console that comes with Tk (on Windows/Mac, but also works on Unix). The console itself provides many more features than the standard console. tkcon works on all platforms where Tcl/Tk is available. It is meant primarily to aid one when working with the little details inside tcl and tk, giving Unix users the GUI console provided by default in the Mac and Windows Tk. It's also not a bad replacement for the default MS-DOS shell (although it needs lots of fine tuning). [http://web.archive.org/web/20070407085224/http://www.cs.nott.ac.uk/~nem/tkcon_see.png] ** Attributes ** website: http://tkcon.sourceforge.net/ current release: 2009-02-26 contact: jeff at hobbs org ** Documentation ** [http://tkcon.sourceforge.net/docs/index.html%|%official reference]: [tkcon.cfg]: [Pasting commands into Tkcon]: Using [TkCon as an application console]: Using [Tkcon as an IDE shell]: [Tkcon remote access over TCP sockets]: [Expanding method names in tkcon]: ** Development ** [https://sourceforge.net/tracker/?group_id=11462&atid=111462%|%bugtracker]: [https://sourceforge.net/tracker/?atid=361462&group_id=11462&func=browse%|%feature tracker]: ** Obtaining ** [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... [ActiveTcl]: 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. If TkCon isn't immediately available in the installed ActiveTcl, use [teacup] to install it. [WinTclTk]: TkCon is included. Unofficial standalone TkCon (with [Tclkit]) : * For [Windows], [Mac OS X] and [Linux] : http://www.zolli.fr/fichiers/tkcon.7z 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 ** Description ** 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), 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. It's often useful to use [Img] with TkCon: ====== tkcon eval package require [Img] ====== ** Installation ** Make a directory (e.g. tkcon-2.5) in your Tcl lib directory, sibling to other packages. Copy the pkgIndex.tcl and tkcon.tcl files there. Load the package and launch the console: ====== package require tkcon tkcon show ====== ---- 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 ====== [adrian]: tkcon version 2.6 on OSX has a bug that prevents accessing the command history via the arrow up key. Emiliano pointed out that the newer version of tkcon http://tkcon.cvs.sourceforge.net/tkcon/tkcon/tkcon.tcl?rev=HEAD%|%here%|% fixes this issue. ** Open Questions ** [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]. ---- [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 } ====== ---- [RLH] 2011-09-21: Can tkcon take color values in hex besides the actual color name? [AMG]: I don't see why not. Just prefix the color value with #, as in `#aaa` or `#ff0000`. See the [http://www.tcl.tk/man/tcl/TkLib/GetColor.htm%|%Tk_GetColor() documentation]. ---- [milarepa] 2013-10-18 03:09:47: How I can add command line history using the up and down keys? For tclsh there are a few readline libraries that can achieve this, but nothing for Tkcon. [IDG]: If you are using tcl 8.6, get a more current version of Tkcon. History recall was always part of tkcon, but was broken by changes to [text] in 8.6, and subsequently repaired. ---- [kap]: A minimalist, easy on the eyes, .tkconrc / tkcon.cfg dark theme. ====== # Disable menu and statusbar set ::tkcon::OPT(showmenu) 0 set ::tkcon::OPT(showstatusbar) 0 # Configure font and colors set ::tkcon::OPT(font) "Consolas 10" set ::tkcon::OPT(font) "{Liberation Mono} 10" set ::tkcon::COLOR(bg) gray10 set ::tkcon::COLOR(cursor) ivory set ::tkcon::COLOR(stdin) ivory set ::tkcon::COLOR(proc) deepskyblue set ::tkcon::COLOR(prompt) green3 set ::tkcon::COLOR(stdout) ivory set ::tkcon::COLOR(var) darkred set ::tkcon::COLOR(blink) goldenrod4 set ::tkcon::COLOR(stderr) red ====== ---- [AMG]: Is there any way to embed Tkcon into an existing [toplevel] window alongside other widgets? I'd like to use it in place of a [[[text]]] widget whose purpose is to collect logs ([[[puts]]] would work well for that) and provide interactive debugging and development. The [[tkcon show -root .whatever]] option only succeeds in specifying the name of the toplevel created by Tkcon. <> Arts and crafts of Tcl-Tk programming | Application | Debugging