Tcl HomeTcl Home hosted by

Google SiteSearch

This page contains information on Tk 4.0, which is a major new release of the Tk toolkit. It is accompanied by a minor new release of Tcl (version 7.4). The final versions of these releases were made on July 1, 1995. These releases run only on Unix systems.

Table of Contents

Download Source Releases for UNIX
What's New in Tcl 7.4 and Tk 4.0
License Terms

Downloading Source Releases for UNIX

If you want to make modifications to Tcl and Tk, you'll need to retrieve the source releases, which are available separately for Tcl and Tk:

When you retrieve a Tcl or Tk release, you'll get a compressed tar file with a name like tcl7.4.tar.Z. To unpack the distribution, invoke shell commands like the following:

zcat tcl7.4.tar.Z | tar xf -

Each of these commands will create a directory named tcl7.4, which includes the sources for all platforms, documentation, and the script library for Tcl 7.4. To compile and install the distribution, follow the instructions in the README file in the distribution directory. Be sure to compile Tcl before Tk, since Tk depends on information in Tcl.

Tcl and Tk should compile with little or no effort on any platform that runs a UNIX-like operating system and the X Window System. This includes workstations from Sun, HP, IBM, SGI, and DEC, PCs running a number of Unix operating systems such as Solaris, Linux, SCO UNIX, and FreeBSD, plus many other platforms such as Cray and NEC supercomputers.

What's new

The best way to learn about the new features in Tk 4.0 is to read the Tk 4.0 Overview and Porting Guide. This document also describes the incompatibilities introduced by Tk 4.0 and gives advice on porting Tk 3.6 scripts to Tk 4.0. If you want even more detail on what has changed in Tk 4.0, see the file changes in the distribution directory. Here are a few of the most significant improvements in Tk 4.0:

  • All of the widgets have been overhauled to provide better Motif compliance.
  • The binding mechanism has been overhauled to provide more flexibility and easier layering of behaviors.
  • There is a general-purpose image mechanism that allows images such as color pictures to appear in many widgets.
  • Text widgets have gone through a major overhaul to support embedded windows, horizontal scrolling, and more display styles.
  • The focus mechanism has been improved greatly to provide a separate focus window for each toplevel and to support keyboard traversal.
  • Many facilities have been modified to support multiple displays better, such as the selection, send, and the input focus.
  • Tk now supports different selections (primary, secondary, etc.) and there is support for the clipboard.
  • Color handling has been improved: Tk deals more gracefully with color exhaustion in a colormap and allows you to create windows with new colormaps and visuals. Tk 4.0 also makes it easy to change the color palette for an application, and the default colors have changed from bisque to gray.


Tk 4.0 is not upward compatible with Tk 3.6. Most scripts written for Tk 3.6 will need some changes in order to run under Tk 4.0. We apologize for the inconvenience this will cause. Here is an explanation in case you're interested.

Ever since the first release of Tk in 1991, I have warned that Tcl/Tk community that there would eventually be a release with major incompatibilities. I knew that I wouldn't be able to get all the features of Tk perfect from the start, and I wanted to have at least one chance to fix the most serious problems, even if it required incompatible changes, so that users wouldn't have to live with them forever. Tk 4.0 is the promised "big one". I've tried to avoid incompatibilities wherever possible, but there were a few places like the binding mechanism where I couldn't find a way to fix the problems without introducing incompatibilities. Again, I apologize for the porting hassles, but I hope you'll agree with me that it was worth it to fix the problems.

Please refer to the porting guide for advice on how to identify potential incompatibilities and fix them.


Patches are available to correct several problems discovered in Tcl 7.4 and Tk 4.0 after they were released. As additional bugs are found, more patches will be released. Before installing a Tcl or Tk release, check for patches and apply any patches that are available. At present, the following patches are available for Tcl 7.4 and Tk4 .0:

To apply a patch, do the following:

  • Fetch the patch file.
  • If the release has already been built and/or installed, type "make distclean" to discard binaries and other derived files (for Tcl 7.5, Tk 4.1, or later releases, do this in the "unix" subdirectory; for earlier releases, do it in the top-level release directory).
  • Change to the top-level source directory for the appropriate release.
  • Apply the patch. If the patch file is named tk4.0p1.patch.gz, type the following command to your shell:
    gunzip -c tk4.0p1.patch.gz | patch -p
    If you don't have the "patch" or "gunzip" programs installed on your machine, you can fetch free versions from any of a number of public FTP sites around the Internet, such as .
  • Follow the instructions in the README file to rebuild the distribution.

Patches must be applied in order for a given release. For example, you must apply Tk 4.0p1 and Tk 4.0p2 before applying Tk 4.0p3. In addition, patches should be applied in clean distribution directories: if you have modified some of the files locally then the patches may not apply correctly. The patch program will generate error messages and leave .rej files around if there are problems applying a patch.