Tcl/Tk: A Developer's Guide


Tcl/Tk (Tool Command Language/Tool Kit) makes it fast and easy to implement any type of application, from games to network analyzers. Tcl/Tk is a full-bodied, mature programming platform used by NASA rocket scientists, Wall Street database experts, Internet designers, and open source programmers around the world. Tcl/Tk's multi-faceted and extensible nature make it ideal for developing end-user GUIs, client/server middleware, Web applications, and more. You can code completely in Tcl, use any of hundreds of ...
See more details below
$64.43 price
(Save 7%)$69.95 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (10) from $54.33   
  • New (9) from $54.33   
  • Used (1) from $65.31   
Tcl/Tk: A Developer's Guide

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
$69.95 price


Tcl/Tk (Tool Command Language/Tool Kit) makes it fast and easy to implement any type of application, from games to network analyzers. Tcl/Tk is a full-bodied, mature programming platform used by NASA rocket scientists, Wall Street database experts, Internet designers, and open source programmers around the world. Tcl/Tk's multi-faceted and extensible nature make it ideal for developing end-user GUIs, client/server middleware, Web applications, and more. You can code completely in Tcl, use any of hundreds of extensions, call C or Java subroutines from Tcl/Tk, or use Tcl to glue legacy applications together.

Written from a programmer's perspective, Tcl/Tk: A Developer's Guide describes how to use Tcl's standard tools and the unique features that make Tcl/Tk powerful: including graphics widgets, packages, namespaces, and extensions. With this book an experienced programmer will be able to code Tcl in a few hours. In just a few chapters you will learn about Tcl features that allow you to isolate and protect your code from being damaged in large applications. You will even learn how to extend the language itself.

Tcl/Tk: A Developer's Guide clearly discusses development tools, proven techniques, and existing extensions. It shows how to use Tcl/Tk effectively and provides many code examples. This fully revised new edition is the complete resource for computer professionals, from systems administrators to programmers. It covers versions 7.4 to 8.4 and includes a CD-ROM containing the interpreters, libraries, and tutorials to get you started quickly. Additional materials in the book include case studies and discussions of techniques for the advanced user.

On the CD-ROM
*Distributions for Tcl 8.3 and 8.4 for Linux, Solaris, Macintosh, and Windows.
*A copy of ActiveTcl from ActiveState.
*The latest release of TclTutor.
*How-to's and tutorials as well as copies of all the tools discussed in the book.
*The author's "Tclsh Spot" articles from :login; magazine and the "Real World" Tcl/Tk chapters from the first edition.
*Demo copies of commercial development tools from ActiveState and NeatWare.
*Many open source Tcl/Tk development tools.
*Tcl/Tk design guidelines.

Read More Show Less

Editorial Reviews

From the Publisher
"Clif's book is both a pleasure to read and a useful reference...I'm sure you'll find it a necessary addition to your professional toolkit."—Marshall T. Rose

"The best computer programmers are astonishingly more productive than average. One reason is that they use good tools, and they use them well. Clif Flynt helps you improve your effectiveness as a developer in both of these ways. Want to take your programming to the next level? Get Tcl/Tk: A Developer's Guide, Second Edition."—Cameron Laird, vice president, Phaseit, Inc., and author of the "Regular Expressions" online column.

Read More Show Less

Product Details

Meet the Author

Clif Flynt is a professional programmer and has been a Tcl advocate since 1994. He has developed Tcl applications for the e-commerce, factory control, computer-based education, network analysis, games, firewall configuration, systems administration, and more. He has taught Tcl/Tk seminars in colleges and corporations around the world and writes regularly on Tcl/Tk for the developer community.
Read More Show Less

Read an Excerpt


A Developer's Guide
By Clif Flynt

Morgan Kaufmann

Copyright © 2012 Elsevier, Inc.
All right reserved.

ISBN: 978-0-12-384718-8

Chapter One

Tcl/Tk Features

Your first question is likely to be "What features will Tcl/Tk offer me that other languages won't?" This chapter gives you an overview of the Tcl/Tk features. It covers the basics of what Tcl/Tk can offer you and what its strengths are compared with several alternatives.

Tcl is a multifaceted language package. You can use Tcl as a command scripting language, as a powerful multi-platform interpreted language, as a rapid prototyping platform, or as the backbone of an application that is primarily written in C or Java. You can use the Tcl and Tk libraries to embed powerful scripting capabilities into a compiled application like C, Java or FORTRAN. Tcl's simple syntax makes single-use scripts (to replace repetitive command typing or graphical user interface (GUI) clicking) quick and easy to write. Tcl's modularization, encapsulation and object oriented features help you develop large (100,000Clines of code) projects. Tcl's extensibility makes it easy to use Tcl as the base language across a broad range of projects, from machine control to database applications to electronic design applications, network test devices, and more.

Tcl is both free software and a commercially supported package. The core Tcl language is primarily supported by a worldwide group of volunteers. Commercial support can be purchased from ActiveState, Noumena Corporation, Cygnus Solutions, and others.

The central site for Tcl/Tk information is The source code repository and some binary snapshots are maintained at Tcl/Tk runtime packages are included with the Linux and FreeBSD packages, and with commercial UNIX distributions such as Solaris, HPUX and Mac OS X. The current binaries for selected systems (including MS-Windows, Linux, Mac OS X, and Solaris) are available from ActiveState (

One of the strengths of Tcl is the number of special-purpose extensions that have been added to the language. Extensions are commonly written in "C" and add high-performance special purpose features that not all users need to the language. The use of extensions keeps the Tcl base language small, while supporting a wide variety of uses.

The most popular Tcl extension is Tk, which stands for Tool Kit. This extension provides tools for graphics programming, including drawing canvases, buttons, menus, and so on. The Tk extension is considered part of the Tcl core and is included in the source code distributions at Sourceforge and most binary distributions.

Other popular extensions to Tcl include [incr Tcl] (which adds support for C++ style object-oriented programming to Tcl) and expect, an extension that simplifies controlling other applications and devices and allows many complex tasks to be easily automated.

With Tcl 8.6 (released in 2010) object-oriented support is part of the core language. The Tcl-OO support provides object-oriented features that mimic smalltalk, Objective-C and C++. Tcl-OO is a powerful programming tool, and can be used to create pure Tcl extensions like [incr Tcl] and XOTcl. Creating these language extensions in pure Tcl, without any compiled code, assures that the extension will run on any platform that the Tcl interpreter can be built for.

Many extensions including expect (for controlling remote systems and routers), TclX (with commands for systems administration), Img and crimp (for image processing) are available both as source code and in binary format. Links to these resources are available from the companion website by visiting:

Dr. John Ousterhout received the 1997 Software System Award from the Association for Computing Machinery (ACM) for inventing Tcl/Tk. This award recognizes the development of a software system that has a lasting influence. The ACM press release says it well.

The Tcl scripting language and its companion Tk user interface toolkit have proved to be a powerful combination. Tcl is widely used as the glue that allows developers to create complex systems using preexisting systems as their components. As one of the first embeddable scripting languages, Tcl has revolutionized the creation of customizable and extensible applications. Tk provides a much simpler mechanism to construct graphical user interfaces than traditional programming languages. The overall Tcl/Tk system has had substantial impact through its wide use in the developer community and thousands of successful commercial applications.


Tcl (pronounced either as the three letters, or as "tickle") stands for Tool Command Language. This name reflects Tcl's strength as a scripting language for gluing other applications together into a new application.

Tcl was developed by Dr. John Ousterhout while he was at the University of California at Berkeley. He and his group developed simulation packages that needed macro languages to control them. After creating a few on-the-fly languages that were tailored to one application and would not work for another, they decided to create an interpreter library they could merge into the other projects. This provided a common parsing package that could be used with each project, and a common base language across the applications.

The original design goal for Tcl was to create a language that could be embedded in other programs and easily extended with new functionality. Tcl was also designed to execute other programs in the manner of a shell scripting language. By placing a small wrapper around the Tcl library, Dr. Ousterhout and his group created tclsh, a program that could be used as an interactive shell and as a script interpreter.

Dr. Ousterhout expected that this solid base for building specialized languages around a common set of core commands and syntax would be useful for building specialized tools. However, as programmers created Tcl extensions with support for graphics, database interaction, distributed processing, and so on, they also started writing applications in pure Tcl. In fact, the Tcl language turned out to be powerful enough that many programs can be written using tclsh as an interpreter with no extensions.

Today, Tcl is widely used for in-house packages, as an embedded scripting language in commercial products, as a rapid prototyping language, as a framework for regression testing, and for 24/7 mission-critical applications. The robustness of the Tcl interpreter is demonstrated by such mission-critical applications as controlling offshore oil platforms, product Q/A and Q/C operations, and running the NBC broadcasting studios. Many companies are open about their use of Tcl and many more consider Tcl their secret competitive edge.

1.1.1 The Standard Tcl Distribution

Tcl is usually distributed with two interpreters (tclsh and wish) , documentation and support libraries. Tclsh (pronounced as ticklish) is a text-based interpreter and wish is that basic interpreter with Tk graphics commands added.

You can use the Tcl interpreter (tclsh) as you would use UNIX shell scripts or MS-DOS batch (.bat) scripts to control and link other programs or use wish to create GUI interfaces to these scripts. The tclsh interpreter provides a more powerful environment than the standard UNIX shell or .bat file interpreters.

The Tcl documentation facility integrates into the native look and feel of the platform Tcl is installed on.

1.1.2 Documentation

On a UNIX/Linux platform, the man pages will be installed under installationDirectory/ man/mann, and can be accessed using the man command. You may need to add the path to the installed manual pages to your MANPATH environment variable.

On Microsoft Windows platforms, you can access the Tcl help from the Start menu, shown in the following illustration.

This will open a window for selecting which help you need. The window is shown in the following illustration.

Selecting Tcl Manual/Tcl Built-In Commands/List Handling from that menu will open a window like that shown in the following illustration. You can select from this window the page of help you need.

A Macintosh running Mac OS X comes with Tcl/Tk installed. You can access the man pages by opening a terminal window and typing man commandName as shown in the following illustration.

If you install a non-Apple version of the tclsh and wish interpreters (for instance whatever the latest ActiveState release is), the new man pages will be installed in a location defined by the installation.

The following image shows a Safari view of the ActiveState html man pages for Tcl 8.6.


A command glue language is used to merge several programs into a single application. UNIX programmers are familiar with the concept of using the output from one program as the input of another via pipes. With a glue language, more complex links between programs become possible. Instead of the linear data flow of a set of piped programs, you can have a tree-like data flow in which several sets of data flow into one application. For example, several programs that report network behavior can be merged with a glue language to create a network activity monitor.

There are good reasons to use simple glue language scripts in your day-to-day computing work.

• A script can glue existing programs into a new entity. It is frequently faster to glue together several small programs to perform a specific task than it is to write a program from scratch.

• A script can repeat a set of actions faster and more reliably than you can type. This is not to disparage your typing skills, but if you have to process 50 files in some consistent manner it will be faster to type a five-line script and have that loop through the file names than to type the same line 50 times.

• You can automate actions that would otherwise take several sets of window and mouse operations. If you have spent much time with GUI programs using Microsoft Windows, Mac OS, or the X Window System, you have probably noticed that there are certain operations you end up doing over and over again, without a hot button you can use to invoke a particular set of button and mouse events. With a scripting language, you can automate a set of actions you perform frequently.

• The script provides a record of commands and can act as procedure documentation.

If you have written scripts using the Bourne shell under UNIX, or .bat files under MS-DOS/MSWindows, you know how painful it can be to make several programs work together. The constructs that make a good interactive user shell don't necessarily make a good scripting language.

Using Tcl, you can invoke other programs, just as you would with shell or .bat scripts, and read any output from those programs into the script for further processing. Tcl provides the string processing and math functionality of awk, sed, and expr without needing to execute other programs. It is easier to write Tcl scripts than Bourne shell scripts with awk and sed, since you have to remember only a single language syntax. Tcl scripts also run more efficiently, since the processing is done within a single executable instead of constantly executing new copies of awk, sed, and so on.

Note that you can only use a script to control programs that support a non-GUI interface. Many GUI-based programs have a command line interface suitable for scripting. Others may support script languages of their own or have a dialog-based mode. Under MS Windows, you can also interact applications using Tcl's DDE and COM extensions.

You can use a wish script as a wrapper around a set of programs originally designed for a text-based user interaction (query/response, or one-at-a-time menu choices) and convert the programs into a modern GUI-based package. This is a very nice way of adding a midlife kicker to an older package by hiding the old-style interactions from users more accustomed to graphical environments.


Excerpted from Tcl/Tk by Clif Flynt Copyright © 2012 by Elsevier, Inc.. Excerpted by permission of Morgan Kaufmann. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Read More Show Less

Table of Contents

Chapter 1: Tcl/Tk Features

Chapter 2: The Mechanics of Using the Tcl and Tk Interpreters

Chapter 3: Introduction to the Tcl Language

Chapter 4: File System, Disk I/O and Sockets

Chapter 5: Using Strings and Lists

Chapter 6: Basic list, array and dict

Chapter 7: Advanced List, array and dict

Chapter 8: Procedure Techniques

Chapter 9: Namespaces

Chapter 10: Basic TclOO

Chapter 11: Advanced TclOO

Chapter 12: Packages and modules

Chapter 13: Introduction to Tk Graphics

Chapter 14: Overview of the canvas Widget

Chapter 15: The text widget and htmllib

Chapter 16: Themed Widgets

Chapter 17: Tk Megawidgets

Chapter 18: Writing a Tcl Extension

Chapter 19: Extensions and Packages

Chapter 20: Programming Tools

Chapter 21: Debugging and Optimization techniques

Chapter 22: Tips and Techniques

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 4 Customer Reviews
  • Anonymous

    Posted November 11, 2012


    Well, shadow here is a nook friend of mine. <_< he seemed he was annoying you guys, so i couldn't sit there reading his side of the conversation.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted November 11, 2012


    A shemale rapes them both.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted November 11, 2012


    Yeah well they need to stop raping us

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted November 11, 2012


    Just ignore him. He's being a creep

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 4 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)