Tcl/Tk - 3rd Edition - ISBN: 9780123847171, 9780123847188


3rd Edition

A Developer's Guide

Authors: Clif Flynt
eBook ISBN: 9780123847188
Paperback ISBN: 9780123847171
Imprint: Morgan Kaufmann
Published Date: 7th February 2012
Page Count: 816
Tax/VAT will be calculated at check-out
File Compatibility per Device

PDF, EPUB, VSB (Vital Source):
PC, Apple Mac, iPhone, iPad, Android mobile devices.

Amazon Kindle eReader.

Institutional Access

Table of Contents





Chapter 1. Tcl/Tk Features

1.1 Tcl Overview

1.2 Tcl As a Glue Language

1.3 Tcl As a General-Purpose Interpreter

1.4 Tcl As an Extensible Interpreter

1.5 Tcl As an Embeddable Interpreter

1.6 Tcl As a Rapid Development Tool

1.7 GUI-Based Programming

1.8 Shipping Products

1.9 Bottom Line

1.10 Problems

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

2.1 The tclsh and wish Interpreters

2.2 Using tclsh/wish Interactively

2.3 Evaluating Tcl Script Files

2.4 Bottom Line

2.5 Problems

Chapter 3. Introduction to the Tcl Language

3.1 Overview of the Basics

3.2 Command Evaluation and Substitutions

3.3 Data Types

3.4 Arithmetic and Boolean Operations

3.5 Modularization

3.6 Bottom Line

3.7 Problems

Chapter 4. Navigating the File System, Basic I/O and Sockets

4.1 Navigating the File System

4.2 Properties of File System Items

4.3 Removing Files

4.4 Input/Output in TCL

4.5 Sockets

4.6 Bottom Line

4.7 Problems

Chapter 5. Using Strings and Lists

5.1 Converting a String into a List

5.2 Examining the List with a for Loop

5.3 Using the foreach Command

5.4 Using string match Instead of string first

5.5 Using lsearch

5.6 The regexp Command

5.7 Creating a Procedure

5.8 Making a Script

5.9 Speed

5.10 Bottom Line

5.11 Problems

Chapter 6. Complex Data Structures with Lists, Arrays and Dicts

6.1 Using the Tcl List

6.2 Using the Dict

6.3 Using the Associative Array

6.4 Trees in Tcl

6.5 Tcl and SQL

6.6 Performance

6.7 Bottom Line

6.8 Problems

Chapter 7. Procedure Techniques

7.1 Arguments to Procedures

7.2 Renaming or Deleting Commands

7.3 Getting Information About Procedures

7.4 Substitution and Evaluation of Strings

7.5 Working with Global and Local Scopes

7.6 Making a Tcl Object

7.7 Bottom Line

7.8 Problems

Chapter 8. Namespaces, Packages and Modules

8.1 Namespaces and Scoping Rules

8.2 Packages

8.3 TCL Modules

8.4 Namespaces and Packages

8.5 Hanoi with a Stack Namespace and Package

8.6 Conventions and Caveats

8.7 Bottom Line

8.8 Problems

Chapter 9. Basic Object-Oriented Programming in Tcl

9.1 Creating a TclOO Class and Object

9.2 Bottom Line

9.3 Problems

Chapter 10. Advanced Object-Oriented Programming in Tcl

10.1 Modifying Classes and Objects

10.2 Modifying Objects

10.3 Examining Classes and Objects

10.4 Examining Objects

10.5 Using TclOO with Callbacks

10.6 Adding New Functionality to TCLOO

10.7 Bottom Line

10.8 Problems

Chapter 11. Introduction to Tk Graphics

11.1 Creating a Widget

11.2 Conventions

11.3 Common Options

11.4 Determining and Setting Options

11.5 The Basic Widgets

11.6 Introducing Widgets: label, button, and entry

11.7 Application Layout: Geometry Managers and Container Widgets

11.8 Selection Widgets: radiobutton, checkbutton, menu, and listbox

11.9 Scrollbar

11.10 The scale Widget

11.11 New Windows

11.12 Interacting with the Event Loop

11.13 Scheduling the Future: after

11.14 Bottom Line

11.15 Problems

Chapter 12. Using the Canvas Widget

12.1 Overview of the canvas Widget

12.2 Creating a canvas Widget

12.3 Creating Displayable canvas Items

12.4 More canvas Widget Subcommands

12.5 The bind and focus Commands

12.6 Creating a Widget

12.7 A Help Balloon: Interacting with the Window Manager

12.8 The image Object

12.9 Bottom Line

12.10 Problems

Chapter 13. The text Widget and htmllib

13.1 Overview of the text Widget

13.2 Creating a text Widget

13.3 Text Widget Subcommands

13.4 HTML Display Package

13.5 Bottom Line

13.6 Problems

Chapter 14. Tk Megawidgets

14.1 Standard Dialog Widgets

14.2 Megawidget Building Philosophy

14.3 Functionality That Makes Megawidgets Possible

14.4 Building a Megawidget

14.5 A Scrolling Listbox Megawidget

14.6 Namespaces and TK Widgets

14.7 Incorporating a Megawidget into a Larger Megawidget

14.8 Making a Modal Megawidget: The grab and tkwait Commands

14.9 Automating Megawidget Construction

14.10 Building Megawidgets with TclOO

14.11 Bottom Line

14.12 Problems

Chapter 15. Extending Tcl

15.1 Functional View of a TCL Extension

15.2 Building an Extension

15.3 An Example

15.4 Complex Data

15.5 Embedding the Tcl Interpreter

15.6 Building Tcl and Tk from Sources

15.7 Bottom Line

15.8 Problems

Chapter 16. Applications with Multiple Environments

16.1 Event Loop

16.2 Threads

16.3 Embedded Tcl Interp and Threading

16.4 Bottom Line

16.5 Problems

Chapter 17. Extensions and Packages

17.1 [incr Tcl]

17.2 Expect

17.3 TclX

17.4 TDBC

17.5 Rivet

17.6 BWidgets

17.7 Graphics Extensions: Img

17.8 Bottom Line

Chapter 18. Programming Tools

18.1 Code Formatter

18.2 Code Checkers

18.3 Debuggers

18.4 Exercising and Regression Testing

18.5 Packaging Tools

18.6 Tcl Extension Generators

18.6 Integrated Development Environments

18.8 Bottom Line

Chapter 19. Tips and Techniques

19.1 Debugging Techniques

19.2 TCL as a Glue Language: The exec Command

19.3 Common Mistakes

19.4 Coding Tips and Techniques

19.5 Optimization

19.6 Techniques for Improving Performance

19.7 Bottom Line



Newly updated with over 150 pages of material on the latest Tcl extensions, Tcl/Tk: A Developer’s Guide is a unique practical tutorial for professional programmers and beginners alike. Starting with a clear picture of the basics, Tcl/Tk covers the variety of tools in this "Swiss army knife" of programming languages, giving you the ability to enhance your programs, extend your application's capabilities, and become a more effective programmer.

This updated edition covers all of the new features of version 8.6, including object-oriented programming and the creation of megawidgets, existing data structure implementations, themed widgets and virtual events. Extensive code snippets and online tutorials in various languages will give you a firm grasp on how to use the Tcl/Tk libraries and interpreters and, most importantly, on what constitutes an effective strategy for using Tcl/Tk.

Key Features

  • Includes the latest features of Tcl/Tk 8.6
  • Covers Tcl development tools, popular extensions, and packages to allow developers to solve real-world problems with Tcl/Tk immediately
  • Provides straightforward explanations for beginners and offers tips, style guidelines, and debugging techniques for advanced users


Applications developers, programmers, software testers, systems software engineers, software architects, and design engineers


No. of pages:
© Morgan Kaufmann 2012
Morgan Kaufmann
eBook ISBN:
Paperback ISBN:


"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's Tcl/Tk: A Developer's Guide, Second Edition helps you improve your effectiveness as a developer in both of these ways. Tcl is a software language with a great return on investment—it achieves portable, powerful, economical results with great economy. Just a few lines of Tcl are enough to create applications that are both interesting and useful. Clif draws on his deep experience as a front-line developer to help you get the most out of Tcl. He writes clearly, and has organized his book with instructive examples that teach the essentials of Tcl. He covers the right material too: Tcl/Tk packs in not just such long-standing Tcl strengths such as its easy networking and graphical user interface, but also the latest breakthroughs with internationalization, widget upgrades, and StarPacks. Want to take your programming to the next level? Get Tcl/Tk: A Developer's Guide, Second Edition."

—Cameron Laird is vice president of Phaseit, Inc. (, where he specializes in Rapid Enterprise Integration with Tcl and related tools. His frequent publications on information technology include the popular "Regular Expressions" column (

About the Authors

Clif Flynt 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.

Affiliations and Expertise

CEO, Noumena Corporation, Dexter, Michigan