The combination of Tool Command Language (Tcl) and its X Window system-based graphical toolkit, Tk, is ideal for quickly developing applications with a graphical interface. This chapter introduces Tcl/Tk through simple examples.

By reading this chapter, you learned the following:

  • Tcl is an interpreted language with a set of commands you can combine, according to a set of rules. Tcl comes with the Red Hat Linux distribution on the companion CD-ROMs.

  • You can learn the Tcl syntax and develop Tcl scripts interactively by running the Tcl command interpreter, tclsh, and entering Tcl commands at the tclsh prompt.

  • Tcl includes built-in commands for most routine tasks, such as reading and writing files, manipulating strings, and running any Linux command. Also, Tcl includes control-flow commands-such as if, for, and while-that enable you to control the sequence of commands the interpreter processes. Finally, you can use Tcl's proc command to write new Tcl commands that use combinations of existing commands.

  • Tk, the Tcl toolkit, is an extension of Tcl that uses the X Window system to enable you to build graphical user interfaces. Tk provides the three-dimensional appearance of Motif, but Tk does not require the Motif toolkit or any other X toolkit. Tk is built on Xlib, which is the C-language Application Programming Interface (API) for X.

  • Tk includes commands for creating many common widgets (user-interface elements), such as buttons, labels, list boxes, and scrollbars. A widget-naming convention specifies the widget hierarchy (the organization of the widgets).

  • To make the graphical interface active, you have to use the bind command to associate Tcl commands with specific keyboard events and mouse events.

  • You can interactively experiment with and create Tk programs by running wish, the windowing shell that can interpret all Tcl and Tk commands.