Tk, by John Ousterhout, is a cross-platform windowing toolkit for Tcl, providing the tools necessary to develop graphical applications that run on Windows, Unix, Mac OS X, and other platforms.
Tk stands for "toolkit".
wish is a Tcl shell that is distributed with Tk and extended by the Tk commands. Historically, Tk was usually used via wish, but the modern way is to treat Tk as any other Tcl extension, using package require to load it. For historical information, see using Tk as a loadable package.
When wish is used on Windows to run Tk programs, there is no associated Windows console, and output to standard channnels (e.g. using puts) is displayed in in a window provided by Tk called "console".
Tk has been adopted by many other languages, including Python and Perl. To this end, most of these other languages also include a full Tcl build, and there is usually some way to access the Tcl interpreter directly. Perl/Tk, on the other hand, rewrote all of Tk in a way that wasn't bound to Tcl, for example. See Tcl and other languages.
see Tk Package
tk is also the name of a Tk command. See:
https://www.tcl-lang.org/man/tcl/TkCmd/tk.htm
The Tk specification is operationally defined by the reference implementation, and the following projects attempt at least some level of conformity to it.
Tk has an Xlib Emulation Layer XLEL, which is one part in making Tk work across different platforms.
That there is such a level is an important reason why Tk generation when X11 headers are missing can be an issue: the Tk source uses X11 headers even when Tk at runtime uses some other windowing system.
[double-buffering examples; ...]
RS 2013-10-08: I just spent some time debugging an app where, mysteriously, switches disappeared from the command line (argv). Turned out that Tk snatched them away. Demonstrations in an interactive tclsh:
% set argv {-c 1 -d 2 -g 3 -n 4 -s 5 -u 6 -v 7} -c 1 -d 2 -g 3 -n 4 -s 5 -u 6 -v 7 % package require Tk this isn't a Tk applicationwindow "6" doesn't exist % set argv 5
The Tk options are documented:
-colormap new -display display -geometry geometry -name name -sync -use id -visual visual --
and a 1-character match is sufficient to take them away (the 5 remained because the -s option does not take an argument). Solution, if you don't want to use any of the Tk options: insert the protective -- at the beginning of argv:
% set argv {-c 1 -d 2 -g 3 -n 4 -s 5 -u 6 -v 7} -c 1 -d 2 -g 3 -n 4 -s 5 -u 6 -v 7 % set argv [linsert $argv 0 --] -- -c 1 -d 2 -g 3 -n 4 -s 5 -u 6 -v 7 % package require Tk 8.4 % set argv -c 1 -d 2 -g 3 -n 4 -s 5 -u 6 -v 7
Martyn Smith: The other choice is to protect the argv variable contents before running the package require that way the end user does not need any special action.
Has anyone been thinking adding a tutorial for Tk into the Tk source code distribution, similar in concept to the Tcl tutorial being added in Tcl 8.5?
DKF: Thinking? Yes. Doing anything about it? No. A set of lessons for Tk would be a very welcome addition!
[Things to explain: Bryan Schofield's posting on multiple Tk interpreters;
AMG: I would like to know more about this since I'm dealing with an intermittent SIGSEGV (and possibly other kind of) crash when using multiple Tk interpreters, specifically in different threads. See [L2 ] for the bug report.
[ Insert here pointers and discussions regarding Tk features ]