> Unfortunately, this simple command line Tcl script now blocks until the
> Tk window is closed by the user. I understand you have no way of
> knowing what kind of script will be executed, Tcl vs Tcl/Tk, without
> actually parsing the script file(s) first. And, with included files
> possible, finding a Tk command or 'package require Tk' may be tedious.
Replace "tedious" with "impossible", given the number of ways that Tk can be
indirectly invoked. And the Tcl/Tk developers apparently don't have any way
of doing it, or they wouldn't need to create multiple variations of the
shell (which require the user to already know how whether it's a Tk script).
The best I can do is *not* do a Tk_Init before the script is invoked, which
requires the user to have a "package require tk" somewhere, and after the
Tcl_EvalFile look for Tk windows. This is necessary because unless I shut
down & reinitialize the interpreter, the next Tk script will fail -- it also
means you cannot have a persistent interpreter executing Tk scripts from the
command line.
I've also added a @TK var function which will allow you to execute a script
without the "package require tk", and which will always create the Tk window
& enter an event loop.
Rex Conn
JP Software