Chapter 8. Getting started with Tcl/Tk on Red Hat Enterprise Linux 8

8.1. Introduction to Tcl/Tk

Tool command language (Tcl) is a dynamic programming language. The interpreter for this language, together with the C library, is provided by the tcl package.

Using Tcl paired with Tk (Tcl/Tk) enables creating cross-platform GUI applications. Tk is provided by the tk package.

Note that Tk can refer to any of the the following:

  • A programming toolkit for multiple languages
  • A Tk C library bindings available for multiple languages, such as C, Ruby, Perl and Python
  • A wish interpreter that instantiates a Tk console
  • A Tk extension that adds a number of new commands to a particular Tcl interpreter

For more information about Tcl/Tk, see the Tcl/Tk manual or Tcl/Tk documentation web page.

8.2. Notable changes in Tcl/Tk 8.6

Major changes in Tcl/Tk 8.6 compared to Tcl/Tk 8.5 are:

  • Object-oriented programming support
  • Stackless evaluation implementation
  • Enhanced exceptions handling
  • Collection of third-party packages built and installed with Tcl
  • Multi-thread operations enabled
  • SQL database-powered scripts support
  • IPv6 networking support
  • Built-in Zlib compression
  • List processing

    Two new commands, lmap and dict map are available, which allow the expression of transformations over Tcl containers.

  • Stacked channels by script

    Two new commands, chan push and chan pop are available, which allow to add or remove transformations to or from I/O channels.

Major changes in Tk include:

  • Built-in PNG image support
  • Busy windows

    A new command, tk busy is available, which disables user interaction for a window or a widget and shows the busy cursor.

  • New font selection dialog interface
  • Angled text support
  • Moving things on a canvas support

For the detailed list of changes between Tcl 8.5 and Tcl 8.6, see Changes in Tcl/Tk 8.6.

8.3. Migrating to Tcl/Tk 8.6

Red Hat Enterprise Linux 7 used Tcl/Tk 8.5. With Red Hat Enterprise Linux 8, Tcl/Tk version 8.6 is provided in the Base OS repository.

This section describes migration path to Tcl/Tk 8.6 for:

8.3.1. Migration path for developers of Tcl extensions

Tcl 8.6 limits direct access to members of the interp structure. For example, if your code reads interp→errorLine, rewrite the code to use the Tcl_GetErrorLine(interp) function.

To make your code compatible with both Tcl 8.5 and Tcl 8.6, use the following code snippet in a header file of your C or C++ application or extension that includes the Tcl library:

# include <tcl.h>
# if !defined(Tcl_GetErrorLine)
# define Tcl_GetErrorLine(interp) (interp→errorLine)
# endif

8.3.2. Migration path for users scripting their tasks with Tcl/Tk

In Tcl 8.6, most scripts work the same way as with the previous version of Tcl. When writing a portable code, make sure to not use the commands that are no longer supported in Tk 8.6:

  • tkIconList_Arrange
  • tkIconList_AutoScan
  • tkIconList_Btn1
  • tkIconList_Config
  • tkIconList_Create
  • tkIconList_CtrlBtn1
  • tkIconList_Curselection
  • tkIconList_DeleteAll
  • tkIconList_Double1
  • tkIconList_DrawSelection
  • tkIconList_FocusIn
  • tkIconList_FocusOut
  • tkIconList_Get
  • tkIconList_Goto
  • tkIconList_Index
  • tkIconList_Invoke
  • tkIconList_KeyPress
  • tkIconList_Leave1
  • tkIconList_LeftRight
  • tkIconList_Motion1
  • tkIconList_Reset
  • tkIconList_ReturnKey
  • tkIconList_See
  • tkIconList_Select
  • tkIconList_Selection
  • tkIconList_ShiftBtn1
  • tkIconList_UpDown

You can check the list of unsupported commands also in the /usr/share/tk8.6/unsupported.tcl file.