You are previewing Tcl/Tk, 3rd Edition.
O'Reilly logo
Tcl/Tk, 3rd Edition

Book Description

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.



  • 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
  • Companion website includes Tcl/Tk tutorials, applications, distributions, and more tools

Table of Contents

  1. Cover Image
  2. Content
  3. Title
  4. Copyright
  5. Foreword
  6. Preface
  7. Acknowledgments
  8. Introduction
  9. Chapter 1. Tcl/Tk Features
    1. 1.1 Tcl Overview
    2. 1.2 Tcl As a Glue Language
    3. 1.3 Tcl As a General-Purpose Interpreter
    4. 1.4 Tcl As an Extensible Interpreter
    5. 1.5 Tcl As an Embeddable Interpreter
    6. 1.6 Tcl As a Rapid Development Tool
    7. 1.7 GUI-Based Programming
    8. 1.8 Shipping Products
    9. 1.9 Bottom Line
    10. 1.10 Problems
  10. Chapter 2. The Mechanics of Using the Tcl and Tk Interpreters
    1. 2.1 The tclsh and wish Interpreters
    2. 2.2 Using tclsh/wish Interactively
    3. 2.3 Evaluating Tcl Script Files
    4. 2.4 Bottom Line
    5. 2.5 Problems
  11. Chapter 3. Introduction to the Tcl Language
    1. 3.1 Overview of the Basics
    2. 3.2 Command Evaluation and Substitutions
    3. 3.3 Data Types
    4. 3.4 Arithmetic and Boolean Operations
    5. 3.5 Modularization
    6. 3.6 Bottom Line
    7. 3.7 Problems
  12. Chapter 4. Navigating the File System, Basic I/O and Sockets
    1. 4.1 Navigating the File System
    2. 4.2 Properties of File System Items
    3. 4.3 Removing Files
    4. 4.4 Input/Output in TCL
    5. 4.5 Sockets
    6. 4.6 Bottom Line
    7. 4.7 Problems
  13. Chapter 5. Using Strings and Lists
    1. 5.1 Converting a String into a List
    2. 5.2 Examining the List with a for Loop
    3. 5.3 Using the foreach Command
    4. 5.4 Using string match Instead of string first
    5. 5.5 Using lsearch
    6. 5.6 The regexp Command
    7. 5.7 Creating a Procedure
    8. 5.8 Making a Script
    9. 5.9 Speed
    10. 5.10 Bottom Line
    11. 5.11 Problems
  14. Chapter 6. Complex Data Structures with Lists, Arrays and Dicts
    1. 6.1 Using the Tcl List
    2. 6.2 Using the Dict
    3. 6.3 Using the Associative Array
    4. 6.4 Trees in Tcl
    5. 6.5 Tcl and SQL
    6. 6.6 Performance
    7. 6.7 Bottom Line
    8. 6.8 Problems
  15. Chapter 7. Procedure Techniques
    1. 7.1 Arguments to Procedures
    2. 7.2 Renaming or Deleting Commands
    3. 7.3 Getting Information About Procedures
    4. 7.4 Substitution and Evaluation of Strings
    5. 7.5 Working with Global and Local Scopes
    6. 7.6 Making a Tcl Object
    7. 7.7 Bottom Line
    8. 7.8 Problems
  16. Chapter 8. Namespaces, Packages and Modules
    1. 8.1 Namespaces and Scoping Rules
    2. 8.2 Packages
    3. 8.3 TCL Modules
    4. 8.4 Namespaces and Packages
    5. 8.5 Hanoi with a Stack Namespace and Package
    6. 8.6 Conventions and Caveats
    7. 8.7 Bottom Line
    8. 8.8 Problems
  17. Chapter 9. Basic Object-Oriented Programming in Tcl
    1. 9.1 Creating a TclOO Class and Object
    2. 9.2 Bottom Line
    3. 9.3 Problems
  18. Chapter 10. Advanced Object-Oriented Programming in Tcl
    1. 10.1 Modifying Classes and Objects
    2. 10.2 Modifying Objects
    3. 10.3 Examining Classes and Objects
    4. 10.4 Examining Objects
    5. 10.5 Using TclOO with Callbacks
    6. 10.6 Adding New Functionality to TCLOO
    7. 10.7 Bottom Line
    8. 10.8 Problems
  19. Chapter 11. Introduction to Tk Graphics
    1. 11.1 Creating a Widget
    2. 11.2 Conventions
    3. 11.3 Common Options
    4. 11.4 Determining and Setting Options
    5. 11.5 The Basic Widgets
    6. 11.6 Introducing Widgets: label, button, and entry
    7. 11.7 Application Layout: Geometry Managers and Container Widgets
    8. 11.8 Selection Widgets: radiobutton, checkbutton, menu, and listbox
    9. 11.9 Scrollbar
    10. 11.10 The scale Widget
    11. 11.11 New Windows
    12. 11.12 Interacting with the Event Loop
    13. 11.13 Scheduling the Future: after
    14. 11.14 Bottom Line
    15. 11.15 Problems
  20. Chapter 12. Using the Canvas Widget
    1. 12.1 Overview of the canvas Widget
    2. 12.2 Creating a canvas Widget
    3. 12.3 Creating Displayable canvas Items
    4. 12.4 More canvas Widget Subcommands
    5. 12.5 The bind and focus Commands
    6. 12.6 Creating a Widget
    7. 12.7 A Help Balloon: Interacting with the Window Manager
    8. 12.8 The image Object
    9. 12.9 Bottom Line
    10. 12.10 Problems
  21. Chapter 13. The text Widget and htmllib
    1. 13.1 Overview of the text Widget
    2. 13.2 Creating a text Widget
    3. 13.3 Text Widget Subcommands
    4. 13.4 HTML Display Package
    5. 13.5 Bottom Line
    6. 13.6 Problems
  22. Chapter 14. Tk Megawidgets
    1. 14.1 Standard Dialog Widgets
    2. 14.2 Megawidget Building Philosophy
    3. 14.3 Functionality That Makes Megawidgets Possible
    4. 14.4 Building a Megawidget
    5. 14.5 A Scrolling Listbox Megawidget
    6. 14.6 Namespaces and TK Widgets
    7. 14.7 Incorporating a Megawidget into a Larger Megawidget
    8. 14.8 Making a Modal Megawidget: The grab and tkwait Commands
    9. 14.9 Automating Megawidget Construction
    10. 14.10 Building Megawidgets with TclOO
    11. 14.11 Bottom Line
    12. 14.12 Problems
  23. Chapter 15. Extending Tcl
    1. 15.1 Functional View of a TCL Extension
    2. 15.2 Building an Extension
    3. 15.3 An Example
    4. 15.4 Complex Data
    5. 15.5 Embedding the Tcl Interpreter
    6. 15.6 Building Tcl and Tk from Sources
    7. 15.7 Bottom Line
    8. 15.8 Problems
  24. Chapter 16. Applications with Multiple Environments
    1. 16.1 Event Loop
    2. 16.2 Threads
    3. 16.3 Embedded Tcl Interp and Threading
    4. 16.4 Bottom Line
    5. 16.5 Problems
  25. Chapter 17. Extensions and Packages
    1. 17.1 [incr Tcl]
    2. 17.2 Expect
    3. 17.3 TclX
    4. 17.4 TDBC
    5. 17.5 Rivet
    6. 17.6 BWidgets
    7. 17.7 Graphics Extensions: Img
    8. 17.8 Bottom Line
  26. Chapter 18. Programming Tools
    1. 18.1 Code Formatter
    2. 18.2 Code Checkers
    3. 18.3 Debuggers
    4. 18.4 Exercising and Regression Testing
    5. 18.5 Packaging Tools
    6. 18.6 Tcl Extension Generators
    7. 18.6 Integrated Development Environments
    8. 18.8 Bottom Line
  27. Chapter 19. Tips and Techniques
    1. 19.1 Debugging Techniques
    2. 19.2 TCL as a Glue Language: The exec Command
    3. 19.3 Common Mistakes
    4. 19.4 Coding Tips and Techniques
    5. 19.5 Optimization
    6. 19.6 Techniques for Improving Performance
    7. 19.7 Bottom Line
  28. Index