Version 11 of console

Updated 2005-04-24 07:48:05

http://purl.org/tcl/home/man/tcl8.4/TkCmd/console.htm

It is my understanding that, for some strange reason, Tk does not yet support console on Unix. That seems very anti-Tk to me - why waste so much time being cross platform and then break it by not offering something so simple?

RS I think it was the other way round: on Unixes, where Tcl originated, you'd start wish at a console and be able to use its stdin/out/err from inside Tcl. Windows apps typically don't have these channels, so the Windows wish console was added to compensate for the loss. That WinTk's console grew more powerful (e.g. you can interact with the interpreter while a script is running, which you can't by default on Unix) justifies your wish to re-implant the original "bugfix" into generic Tk - or pull tkcon into the core?


Certainly I can see having at least the minimal console everywhere -I would also be heartily in favor of tkcon or something better being the default console across platforms.

Of course, in both cases, a TIP is going to be needed...


Actually, would a TIP really be needed to activate a command that was already present on the other platforms?


See console for Unix.

JL Why hasn't the console every been made available on Unix? (I've checked up to 8.4) console.n and console.tcl are already installed, and it is useful for simple interactive debugging. All that's needed is to supply the 'console' command, or use something like the workaround above.

This is not the same as adding tkcon. All I want is just the same, simple console across all platforms.


LV I don't recall whether a TIP has been filed to make this happen.


RS uses the following binding to have a console for debugging pop up when needed:

 bind . ? {catch {console show}}

RA2 Hi! I'd like to attach a console to my TCL program. What code do I enter, where and how to start a console maximized (100%)? Thanks I appreciate!

RS: See console and Maximizing a toplevel window, but here's what works for me on Win XP:

 % console show
 % console eval {wm state . zoomed}

RA2 Thanks so much Richard! You are very kind!


MG Feb 16th 2005 - Out of sheer curiousity, I had a quick poke around to see if I could find how to change the prompt on the console, and found this (in ActiveTcl 8.4.9.0 on WinXP):

  (Griffiths) 2 % console eval {set ::tk::console::defaultPrompt}
  subst {([file tail [pwd]]) [history nextid] % }

I don't know if that's the default on all platforms, and I doubt that this is the Right Way to change the prompt (I think the internals of the console are subject to change without notification), but for now at least this works..

  console eval {set ::tk::console::defaultPrompt {return "% "}}
  proc % {args} {
     eval $args
  }

That sets the prompt to "% ", so that you can copy things you've typed into the console and paste them back in to run them again without having to remove the prompt. If you want the same effect but you want to keep the line number, just use

  console eval {set ::tk::console::defaultPrompt {subst {% ([history nextid]) }}
  proc % {lineNumber args} {
    eval $args
  }

2005-04-23 Derek Peschel Evidently the discussion goes here and the code goes on the console for UNIX page. See my questions in Ask, and it shall be given # 2. I've put these items here because they aren't questions.

Brian Theado and I and maybe others have changed the console on UNIX script as part of the TkOutline project [L1 ]. After someone helps answer two questions I have, I think the changes should be propagated back here. They are:

  1. The script has a few more comments. I also changed the punctuation of the comments for no other reason than personal taste.
  2. It uses the $_ variable when evaluating the library console.tcl file as well as when checking it for readability. I changed the name of the library file (so I could have my own version with a bigger font) and wasted some time wondering why my changes weren't being read.
  3. Maybe more; I haven't looked in detail.

Tk syntax help - Arts and crafts of Tcl-Tk programming - Category Command, a part of the Tk package