You are previewing Practical Programming in Tcl and Tk, Fourth Edition.
O'Reilly logo
Practical Programming in Tcl and Tk, Fourth Edition

Book Description

Practical Programming in Tcl/Tk, 4th edition

  • The Tcl/Tk bestseller fully updated for Tcl 8.4!

  • Authoritative coverage of every Tcl and Tk command in the core toolkits

  • State-of-the-art Tk GUI coverage for Tcl, Perl, Python, and Ruby developers

  • Covers all key Tcl 8.4 enhancements: VFS, internationalization and performance improvements, new widgets, and much more

  • Covers multi-threaded Tcl applications and Starkits, a revolutionary way to package and deploy Tcl applications

  • CD-ROM: Source and binary Tcl/Tk distributions and extensions for Windows®, Linux™, Solaris™, and Macintosh®, plus all code from the book

  • The Tcl/Tk bestseller, now completely updated for Tcl 8.4!

    The world's #1 guide to Tcl/Tk has been thoroughly updated to reflect Tcl/Tk8.4's powerful improvements in functionality, flexibility, and performance!Brent Welch, Ken Jones, and Jeffrey Hobbs, three of the world1s leading Tcl/Tk experts, cover every facet of Tcl/Tk programming, including cross-platform scripting and GUI development, networking, enterprise application integration, and much more.Coverage includes:

  • Systematic explanations and sample code for all Tcl/Tk 8.4 core commands

  • Complete Tk GUI development guidance--perfect for developers working with Perl, Python, or Ruby

  • Insider's insights into Tcl 8.4's key enhancements: VFS layer, internationalized font/character set support, new widgets, and more

  • Definitive coverage of TclHttpd web server--written by its creator

  • New ways to leverage Tcl/Tk 8.4's major performance improvements

  • Advanced coverage: threading, Safe Tcl, Tcl script library, regular expressions, and namespaces

  • Whether you1re upgrading to Tcl/Tk 8.4, or building GUIs for applicationscreated with other languages, or just searching for a better cross-platformscripting solution, Practical Programming in Tcl and Tk, Fourth Editiondelivers all you need to get results!

    The accompanying CD-ROM includes source and binary distributionsof Tcl/Tk, Tcl extensions, and tools for Windows 9x/2000/XP, Linux, Solaris,and Macintosh, plus all the code from the book.

    Table of Contents

    1. Copyright
      1. Dedication
    2. List of Examples
    3. List of Tables
    4. Preface
      1. Why Tcl?
      2. Tcl and Tk Versions
      3. Extending Tcl and Tk
      4. Tcl on the World Wide Web
      5. Ftp Archives
      6. Newsgroups
      7. Who Should Read This Book
      8. How to Read This Book
      9. On-line Examples
      10. Typographic Conventions
      11. Hot Tips
      12. Book Organization
      13. What's New in the Fourth Edition
      14. Other Tcl Books
      15. First Edition Thanks
      16. Second Edition Thanks
      17. Third Edition Thanks
      18. Fourth Edition Thanks
      19. Contact the Author
    5. I. Tcl Basics
      1. 1. Tcl Fundamentals
        1. Tcl Commands
        2. Hello, World!
        3. Variables
        4. Command Substitution
        5. Math Expressions
        6. Backslash Substitution
        7. Grouping with Braces and Double Quotes
          1. Square Brackets Do Not Group
          2. Grouping before Substitution
          3. Grouping Math Expressions with Braces
          4. More Substitution Examples
        8. Procedures
        9. A Factorial Example
        10. More about Variables
          1. Funny Variable Names
          2. The unset Command
          3. Using info to Find Out about Variables
        11. More about Math Expressions
        12. Comments
        13. Substitution and Grouping Summary
        14. Fine Points
        15. Reference
          1. Backslash Sequences
          2. Arithmetic Operators
          3. Built-in Math Functions
          4. Core Tcl Commands
      2. 2. Getting Started
        1. The source Command
        2. UNIX Tcl Scripts
        3. Windows Start Menu
        4. Macintosh OS 8/9 and ResEdit
          1. Macintosh OS X
        5. The console Command
        6. Command-Line Arguments
          1. Command-Line Options to Wish
        7. Predefined Variables
      3. 3. The Guestbook CGI Application
        1. A Quick Introduction to HTML
        2. CGI for Dynamic Pages
        3. The guestbook.cgi Script
          1. Using a Script Library File
          2. Beginning the HTML Page
          3. Sample Output of the CGI Script
          4. Using a Tcl Array for the Database
        4. Defining Forms and Processing Form Data
          1. The newguest.html Form
          2. The ncgi and cgi.tcl Packages
          3. The newguest.cgi Script
          4. Using Tcl Scripts to Store Data
        5. Handling Errors in CGI Scripts
        6. Next Steps
      4. 4. String Processing in Tcl
        1. The string Command
          1. String Indices
          2. Strings and Expressions
          3. String Matching
          4. Character Classes
          5. Mapping Strings
        2. The append Command
        3. The format Command
        4. The scan Command
        5. The binary Command
          1. Format Templates
          2. Examples
          3. Binary Data and File I/O
        6. Related Chapters
      5. 5. Tcl Lists
        1. Tcl Lists
        2. Constructing Lists
          1. The list command
          2. The lappend Command
          3. The lset Command
          4. The concat Command
        3. Getting List Elements: llength, lindex, and lrange
        4. Modifying Lists: linsert and lreplace
        5. Searching Lists: lsearch
        6. Sorting Lists: lsort
        7. The split Command
        8. The join Command
        9. Related Chapters
      6. 6. Control Structure Commands
        1. If Then Else
        2. Switch
          1. Comments in switch Commands
        3. While
        4. Foreach
          1. Multiple Loop Variables
          2. Multiple Value Lists
        5. For
        6. Break and Continue
        7. Catch
          1. Catching More Than Errors
        8. Error
        9. Return
      7. 7. Procedures and Scope
        1. The proc Command
        2. Changing Command Names with rename
        3. Scope
        4. The global Command
        5. Call by Name Using upvar
        6. Variable Aliases with upvar
          1. Associating State with Data
          2. Namespaces and upvar
          3. Commands That Take Variable Names
      8. 8. Tcl Arrays
        1. Array Syntax
          1. Complex Indices
          2. Array Variables
        2. The array Command
          1. Converting Between Arrays and Lists
          2. Passing Arrays by Name
        3. Building Data Structures with Arrays
          1. Simple Records
          2. A Stack
          3. A List of Arrays
          4. A Simple In-Memory Database
          5. Alternatives to Using Arrays
      9. 9. Working with Files and Programs
        1. Running Programs with exec
          1. The auto_noexec Variable
          2. Limitations of exec on Windows
          3. AppleScript on Macintosh
        2. The file Command
        3. Cross-Platform File Naming
          1. Building up Pathnames: file join
          2. Chopping Pathnames: split, dirname, tail
        4. Manipulating Files and Directories
          1. Copying Files
          2. Creating Directories
          3. Symbolic and Hard Links
          4. Deleting Files
          5. Renaming Files and Directories
        5. File Attributes
        6. Input/Output Command Summary
        7. Opening Files for I/O
          1. Opening a Process Pipeline
          2. Expect
        8. Reading and Writing
          1. The puts and gets Commands
          2. The read Command
          3. Platform-Specific End of Line Characters
          4. Random Access I/O
          5. Closing I/O Channels
        9. The Current Directory — cd and pwd
        10. Matching File Names with glob
          1. Expanding Tilde in File Names
        11. The exit and pid Commands
        12. Environment Variables
        13. The registry Command
    6. II. Advanced Tcl
      1. 10. Quoting Issues and Eval
        1. Constructing Code with the list Command
          1. The eval Command
          2. Commands That Concatenate Their Arguments
          3. Commands That Use Callbacks
          4. Command Prefix Callbacks
          5. Constructing Procedures Dynamically
        2. Exploiting the concat inside eval
          1. Using eval in a Wrapper Procedure.
          2. Correct Quoting with eval
        3. The uplevel Command
        4. The subst Command
          1. String Processing with subst
      2. 11. Regular Expressions
        1. When to Use Regular Expressions
          1. Avoiding a Common Problem
        2. Regular Expression Syntax
          1. Matching Characters
          2. Character Sets
          3. Quantifiers
          4. Alternation
          5. Anchoring a Match
          6. Backslash Quoting
          7. Matching Precedence
          8. Capturing Subpatterns
        3. Advanced Regular Expressions
          1. Compatibility with Patterns in Tcl 8.0
          2. Backslash Escape Sequences
          3. Character Classes
          4. Nongreedy Quantifiers
          5. Bound Quantifiers
          6. Back References
          7. Look-ahead
          8. Character Codes
          9. Collating Elements
          10. Equivalence Classes
          11. Newline Sensitive Matching
          12. Embedded Options
          13. Expanded Syntax
        4. Syntax Summary
        5. The regexp Command
          1. A Pattern to Match URLs
          2. Bugs When Mixing Greedy and Non-Greedy Quantifiers
          3. Sample Regular Expressions
        6. The regsub Command
        7. Transforming Data to Program with regsub
          1. URL Decoding
          2. CGI Argument Parsing
          3. Decoding HTML Entities
          4. A Simple HTML Parser
          5. Stripping HTML Comments
        8. Other Commands That Use Regular Expressions
      3. 12. Script Libraries and Packages
        1. Locating Packages: The auto_path Variable
        2. Using Packages
          1. Loading Packages Automatically
          2. Packages Implemented in C Code
        3. Summary of Package Loading
        4. The package Command
        5. Libraries Based on the tclIndex File
        6. The unknown Command
          1. How Auto Loading Works
          2. Disabling the Library Facility: auto_noload
        7. Interactive Conveniences
          1. Auto Execute
          2. History
          3. Abbreviations
        8. Tcl Shell Library Environment
          1. Locating the Tcl Script Library
          2. tcl_findLibrary
        9. Coding Style
          1. A Module Prefix for Procedure Names
          2. A Global Array for State Variables
          3. The Official Tcl Style Guide
      4. 13. Reflection and Debugging
        1. The clock Command
        2. The info Command
          1. Variables
          2. Procedures
          3. The Call Stack
          4. Command Evaluation
          5. Scripts and the Library
          6. Version Numbers
          7. Execution Environment
        3. Cross-Platform Support
        4. Tracing Variables and Commands
          1. Command Tracing
          2. Read-Only Variables
          3. Creating an Array with Traces
        5. Interactive Command History
          1. History Syntax
          2. A Comparison to C Shell History Syntax
        6. Debugging
        7. Tcl Dev Kit
          1. Debugger with Coverage
          2. Checker
          3. Compiler
          4. TclApp
          5. Tcl Service Manager
          6. Inspector
        8. Other Tools
          1. The tkcon Console
          2. Critcl
          3. The bgerror Command
          4. The tkerror Command
        9. Performance Tuning
          1. Time stamps in a Log
          2. The Tcl Compiler
      5. 14. Namespaces
        1. Using Namespaces
        2. Namespace Variables
          1. Qualified Names
        3. Command Lookup
        4. Nested Namespaces
        5. Importing and Exporting Procedures
        6. Callbacks and Namespaces
        7. Introspection
        8. The namespace Command
        9. Converting Existing Packages to use Namespaces
        10. [incr Tcl] Object System
        11. xotcl Object System
        12. Notes
          1. Names for Widgets, Images, and Interpreters
          2. The variable command at the global scope
          3. Auto Loading and auto_import
          4. Namespaces and uplevel
          5. Naming Quirks
          6. Miscellaneous
      6. 15. Internationalization
        1. Character Sets and Encodings
          1. The System Encoding
          2. File Encodings and fconfigure
          3. Scripts in Different Encodings
          4. Unicode and UTF-8
          5. The Binary Encoding
          6. Conversions Between Encodings
          7. The encoding Command
        2. Message Catalogs
          1. Specifying a Locale
          2. Managing Message Catalog Files
          3. Message Catalogs and Namespaces
          4. The msgcat package
      7. 16. Event-Driven Programming
        1. The Tcl Event Loop
        2. The after Command
        3. The fileevent Command
        4. The vwait Command
        5. The fconfigure Command
          1. Nonblocking I/O
          2. The fblocked Command
          3. Buffering
          4. End of Line Translations
          5. End of File Character
          6. Serial Devices
          7. Character Set Encodings
          8. Configuring Read-Write Channels
      8. 17. Socket Programming
        1. Networking Extensions for Tcl
          1. Scotty
          2. Standard Tcl Library
          3. HTTP
        2. Client Sockets
          1. Client Socket Options
        3. Server Sockets
          1. Server Socket Options
        4. The Echo Service
        5. Fetching a URL with HTTP
          1. Proxy Servers
          2. The HEAD Request
          3. The GET and POST Requests
          4. The fcopy Command
        6. The http Package
          1. http::config
          2. http::geturl
          3. http::formatQuery
          4. http::register and http::unregister
          5. http::reset
          6. http::cleanup
        7. Basic Authentication
      9. 18. TclHttpd Web Server
        1. Integrating TclHttpd with Your Application
          1. TclHttpd Architecture
          2. Adding Code to TclHttpd
          3. Custom Main Programs
        2. Domain Handlers
          1. Connection State and Query Data
          2. The html and ncgi Packages
          3. Returning Results
        3. Application Direct URLs
          1. Using Query Data
          2. Returning Other Content Types
        4. Document Types
        5. HTML + Tcl Templates
          1. Where to Put Your Tcl Code
          2. Templates for Site Structure
          3. Using Variables for Important Site Information
        6. Form Handlers
          1. Application Direct Handlers
          2. Template Form Handlers
          3. Self-Posting Forms
          4. The html Package
        7. Programming Reference
        8. Standard Application Direct URLs
          1. Status
          2. Debugging
          3. Sending Email
        9. The TclHttpd Distribution
          1. Quick Start
          2. Inside the Distribution
        10. Server Configuration
          1. Command Line Arguments
          2. Server Name and Port
          3. User and Group ID
          4. Webmaster Email
          5. Document Root
          6. Other Document Settings
          7. Document Templates
          8. Log Files
          9. CGI Directories
      10. 19. Multiple Interpreters and Safe-Tcl
        1. The interp Command
        2. Creating Interpreters
          1. The Interpreter Hierarchy
          2. The Interpreter Name as a Command
          3. Use list with interp eval
        3. Safe Interpreters
        4. Command Aliases
          1. Alias Introspection
        5. Hidden Commands
        6. Substitutions
        7. I/O from Safe Interpreters
        8. The Safe Base
        9. Security Policies
          1. Limited Socket Access
          2. Limited Temporary Files
          3. Safe after Command
      11. 20. Safe-Tk and the Browser Plugin
        1. Tk in Child Interpreters
          1. Embedding Tk Windows
          2. Safe-Tk Restrictions
        2. The Browser Plugin
          1. The embed_args and plugin Variables
          2. Example Plugins
          3. Setting Up the plugin
        3. Security Policies and Browser Plugin
          1. The Browser Package
        4. Configuring Security Policies
          1. The config/plugin.cfg File
          2. Policy Configuration Files
          3. Security Policy Features
          4. Creating New Security Policies
      12. 21. Multi-Threaded Tcl Scripts
        1. What are Threads?
        2. Thread Support in Tcl
          1. Obtaining a Thread-Enabled Tcl Interpreter
          2. Using Extensions in Multi-Threaded Scripts
        3. Getting Started with the Thread Extension
          1. Creating Threads
          2. Creating Joinable Threads
        4. Sending Messages to Threads
          1. Synchronous Message Sending
          2. Asynchronous Message Sending
        5. Preserving and Releasing Threads
        6. Error Handling
        7. Shared Resources
        8. Managing I/O Channels
          1. Accessing Files from Multiple Threads
          2. Transferring Channels between Threads
        9. Shared Variables
        10. Mutexes and Condition Variables
          1. Mutexes
          2. Condition Variables
        11. Thread Pools
        12. The Thread Package Commands
          1. The thread Namespace
          2. The tsv Namespace
          3. The tpool Namespace
      13. 22. Tclkit and Starkits
        1. Getting Started with Tclkit
          1. Inside a Starkit
          2. Deploying Applications as Starkits
        2. Virtual File Systems
          1. Accessing a Zip File Through a VFS
        3. Using sdx to Bundle Applications
          1. Creating a Simple Starkit
          2. Examining a Starkit
          3. Standard Package Organization
          4. Creating a Starpack
        4. Exploring the Virtual File System in a Starkit
        5. Creating tclhttpd.kit
        6. Creating a Shared Starkit
        7. Metakit
          1. Metakit Data Model
          2. Examining a Metakit Database
          3. Creating a Metakit View
          4. Storing Application Data in a Starkit
          5. Wikit and the Tcler's Wiki
        8. More Ideas
          1. Document Bundles
          2. Self-Updating Applications
          3. Simple Installers
    7. III. Tk Basics
      1. 23. Tk Fundamentals
        1. Hello, World! in Tk
        2. Naming Tk Widgets
        3. Configuring Tk Widgets
        4. Tk Widget Attributes and the Resource Database
          1. The Tk Manual Pages
        5. Summary of the Tk Commands
          1. Widget Commands
          2. Widget Manipulation Commands
          3. Support Procedures
        6. Other Widget Sets
          1. BLT
          2. Tix
          3. [incr Tk] and [incr Widgets]
          4. BWidgets
          5. TkTable
      2. 24. Tk by Example
        1. ExecLog
          1. Window Title
          2. A Frame for Buttons
          3. Command Buttons
          4. A Label and an Entry
          5. Key Bindings and Focus
          6. A Resizable Text and Scrollbar
          7. The Run Procedure
          8. The Log Procedure
          9. The Stop Procedure
          10. Cross-Platform Issues
        2. The Example Browser
          1. More about Resizing Windows
          2. Managing Global State
          3. Searching through Files
          4. Cascaded Menus
          5. A Read-Only Text Widget
        3. A Tcl Shell
          1. Text Marks, Tags, and Bindings
          2. Multiple Interpreters
          3. Native Look and Feel
      3. 25. The Pack Geometry Manager
        1. Packing toward a Side
          1. Shrinking Frames and pack propagate
        2. Horizontal and Vertical Stacking
        3. The Cavity Model
        4. Packing Space and Display Space
          1. The -fill Option
          2. Internal Padding with -ipadx and -ipady
          3. External Padding with -padx and -pady
        5. Resizing and -expand
        6. Anchoring
        7. Packing Order
          1. Introspection
          2. Pack the Scrollbar First
        8. Choosing the Parent for Packing
        9. Unpacking a Widget
        10. Packer Summary
          1. The pack Command
        11. Window Stacking Order
      4. 26. The Grid Geometry Manager
        1. A Basic Grid
          1. The -sticky Setting
          2. External Padding with -padx and -pady
          3. Internal Padding with -ipadx and -ipady
          4. Multiple Widgets in a Cell
        2. Spanning Rows and Columns
        3. Row and Column Constraints
          1. Row and Column Padding
          2. Minimum Size
          3. Managing Resize Behavior
          4. Uniform Columns
        4. The grid Command
      5. 27. The Place Geometry Manager
        1. place Basics
        2. The Pane Manager
          1. Parsing Arguments and Maintaining State
          2. Sticky Geometry Settings
          3. Event Bindings
          4. Managing the Layout
        3. The place Command
      6. 28. The Panedwindow Widget
        1. Using the Panedwindow
          1. Manipulating the Pane Contents
        2. Programming Panedwindow Widgets
        3. Panedwindow Attributes
      7. 29. Binding Commands to Events
        1. The bind Command
        2. The bindtags Command
          1. Focus and Key Events
          2. Using break and continue in Bindings
          3. Defining New Binding Tags
        3. Event Syntax
          1. Keyboard Events
          2. Mouse Events
          3. Other Events
          4. Bindings on Top-level Windows
        4. Modifiers
        5. Event Sequences
        6. Virtual Events
        7. Generating Events
        8. Event Summary
          1. Event Command Syntax
          2. Event Keywords
    8. IV. Tk Widgets
      1. 30. Buttons and Menus
        1. Button Commands and Scope Issues
        2. Buttons Associated with Tcl Variables
        3. Button Attributes
        4. Button Operations
        5. Menus and Menubuttons
          1. A Menu Bar
          2. System Menus
          3. Pop-Up Menus
          4. Option Menus
          5. Multicolumn Palette Menus
        6. Menu Bindings and Events
          1. Keyboard Traversal
          2. Menu Virtual Events
        7. Manipulating Menus and Menu Entries
        8. Menu Attributes
        9. A Menu by Name Package
          1. Menu Accelerators
      2. 31. The Resource Database
        1. An Introduction to Resources
          1. Resource Patterns
        2. Loading Option Database Files
        3. Adding Individual Database Entries
        4. Accessing the Database
        5. User-Defined Buttons
        6. User-Defined Menus
          1. Application and User Resources
          2. Expanding Variables
      3. 32. Simple Tk Widgets
        1. Frames, Labelframes, and Toplevel Windows
          1. Attributes for Frames, Labelframes, and Toplevels
          2. Using Labelframe Widgets
          3. Embedding Other Applications
          4. Toplevel Window Styles
        2. The Label Widget
          1. Label Width and Wrap Length
          2. Label Attributes
        3. The Message Widget
          1. Message Attributes
          2. Arranging Labels and Messages
        4. The Scale Widget
          1. Scale Bindings
          2. Scale Attributes
          3. Programming Scales
        5. The bell Command
      4. 33. Scrollbars
        1. Using Scrollbars
        2. The Scrollbar Protocol
          1. The Scrollbar set Operation
          2. The xview and yview Operations
        3. The Scrollbar Widget
          1. Scrollbar Bindings
          2. Scrollbar Attributes
          3. Programming Scrollbars
      5. 34. The Entry and Spinbox Widgets
        1. Using Entry Widgets
          1. Validating Entry Contents
          2. Tips for Using Entry Widgets
        2. Using Spinbox Widgets
        3. Entry and Spinbox Bindings
        4. Entry and Spinbox Attributes
        5. Programming Entry and Spinbox Widgets
      6. 35. The Listbox Widget
        1. Using Listboxes
          1. Manipulating Listbox Contents
          2. Programming Listboxes
        2. The Listbox Widget
        3. Listbox Bindings and Events
          1. Browse Select Mode
          2. Single Select Mode
          3. Extended Select Mode
          4. Multiple Select Mode
          5. Scroll Bindings
          6. Listbox Virtual Events
        4. Listbox Attributes
          1. Geometry Gridding
      7. 36. The Text Widget
        1. Text Indices
          1. Inserting and Deleting Text
          2. Index Arithmetic
          3. Comparing Indices
        2. Text Marks
          1. Mark Gravity
        3. Text Tags
          1. Tag Attributes
          2. Mixing Attributes from Different Tags
          3. Line Spacing and Justification
          4. Tab Stops
        4. The Selection
        5. Tag Bindings
        6. Searching Text
        7. Embedded Widgets
        8. Embedded Images
        9. Looking inside the Text Widget
          1. Looking at Tags
          2. Looking at Marks
          3. Dumping the Contents
        10. The Undo Mechanism
        11. Text Bindings and Events
          1. Text Bindings
          2. Text Virtual Events
        12. Text Operations
        13. Text Attributes
      8. 37. The Canvas Widget
        1. Canvas Coordinates
        2. Hello, World!
          1. Canvas Tags
        3. The Min Max Scale Example
        4. Canvas Objects
          1. Canvas Widget and Canvas Object State Options
          2. Dashed Lines
          3. Arc Items
          4. Bitmap Items
          5. Image Items
          6. Line Items
          7. Oval Items
          8. Polygon Items
          9. Rectangle Items
          10. Text Items
          11. Window Items
        5. Canvas Operations
        6. Generating Postscript
        7. Canvas Attributes
        8. Hints
          1. Screen Coordinates vs. Canvas Coordinates
          2. Large Coordinate Spaces
          3. Scaling and Rotation
          4. Resources
          5. Objects with Many Points
          6. Selecting Canvas Items
    9. V. Tk Details
      1. 38. Selections and the Clipboard>
        1. The Selection Model
        2. The selection Command
        3. The clipboard Command
        4. Selection Handlers
          1. A Canvas Selection Handler
      2. 39. Focus, Grabs, and Dialogs
        1. Standard Dialogs
          1. Message Box
          2. File and Directory Dialogs
          3. Color Dialog
        2. Custom Dialogs
          1. Input Focus
          2. The focus Command
          3. Keyboard Focus Traversal
          4. Grabbing the Focus
          5. The tkwait Command
          6. Destroying Widgets
          7. The focus, grab, tkwait sequence
          8. Prompter Dialog
          9. Keyboard Shortcuts and Focus
        3. Animation with the update Command
      3. 40. Tk Widget Attributes
        1. Configuring Attributes
        2. Size
        3. Borders and Relief
        4. The Focus Highlight
        5. Padding and Anchors
          1. Putting It All Together
      4. 41. Color, Images, and Cursors
        1. Colors
          1. Color Palettes
          2. Color Values
        2. Colormaps and Visuals
        3. Bitmaps and Images
          1. The image Command
          2. Bitmap Images
          3. The bitmap Attribute
          4. Photo Images
        4. The Text Insert Cursor
        5. The Mouse Cursor
      5. 42. Fonts and Text Attributes
        1. Naming a Font
          1. Named Fonts
          2. System Fonts
          3. Unicode Fonts
        2. X Font Names
          1. Font Failures before Tk 8.0
        3. Font Metrics
        4. The font Command
        5. Text Attributes
          1. Layout
          2. Selection Attributes
        6. Gridding, Resizing, and Geometry
        7. A Font Selection Application
      6. 43. Send
        1. The send Command
          1. Send and X Authority
        2. The Sender Script
        3. Communicating Processes
        4. Remote eval through Sockets
      7. 44. Window Managers and Window Information
        1. The wm Command
          1. Toplevel Size, Placement, and Decoration
          2. Icons
          3. Application Session State
          4. Miscellaneous Window Manager Operations
        2. The winfo Command
          1. Sending Commands between Applications
          2. Widget Family Relationships
          3. Widget Size
          4. Widget Location
          5. Virtual Root Window
          6. Atoms and IDs
          7. Colormaps and Visuals
        3. The tk Command
      8. 45. Managing User Preferences
        1. App-Defaults Files
        2. Defining Preferences
        3. The Preferences User Interface
        4. Managing the Preferences File
        5. Tracing Changes to Preference Variables
        6. Improving the Package
      9. 46. A User Interface to Bindings
        1. A Pair of Listboxes Working Together
        2. The Editing Interface
        3. Saving and Loading Bindings
    10. VI. C Programming
      1. 47. C Programming and Tcl
        1. Basic Concepts
          1. Getting Started
          2. C Command Procedures and Data Objects
          3. SWIG
          4. Tcl Initialization
          5. Calling Out to Tcl Scripts
          6. Using the Tcl C Library
        2. Creating a Loadable Package
          1. The load Command
          2. The Package Initialization Procedure
          3. Using Tcl_PkgProvide
        3. A C Command Procedure
          1. The String Command Interface
          2. Result Codes from Command Procedures
          3. Managing the String Result
          4. The Tcl_Obj Command Interface
          5. Managing Tcl_Obj Reference Counts
          6. Modifying Tcl_Obj Values
          7. Pitfalls of Shared Tcl_Obj Values
        4. The blob Command Example
          1. Creating and Destroying Hash Tables
          2. Tcl_Alloc, ckalloc, and malloc
          3. Parsing Arguments and Tcl_GetIndexFromObj
          4. Creating and Removing Elements from a Hash Table
          5. Building a List
          6. Keeping References to Tcl_Obj Values
          7. Using Tcl_Preserve and Tcl_Release to Guard Data
        5. CONST in the Tcl 8.4 APIs
        6. Strings and Internationalization
          1. The DString Interface
          2. Character Set Conversions
        7. Tcl_Main and Tcl_AppInit
          1. Tk_Main
        8. The Event Loop
        9. Invoking Scripts from C
          1. Variations on Tcl_Eval
          2. Bypassing Tcl_Eval
      2. 48. Compiling Tcl and Extensions
        1. Standard Directory Structure
          1. The Source Distribution
          2. The Installation Directory Structure
        2. Building Tcl from Source
          1. Configure and Autoconf
          2. Standard Configure Flags
          3. Installation
        3. Using Stub Libraries
        4. Using autoconf
          1. The tcl.m4 File
          2. Makefile Templates
        5. The Sample Extension
          1. configure.in
          2. Makefile.in
          3. Standard Header Files
          4. Using the Sample Extension
      3. 49. Writing a Tk Widget in C
        1. Initializing the Extension
        2. The Widget Data Structure
        3. The Widget Class Command
        4. The Widget Instance Command
        5. Configuring and Reconfiguring Attributes
        6. Specifying Widget Attributes
        7. Displaying the Clock
        8. The Window Event Procedure
        9. Final Cleanup
      4. 50. C Library Overview
        1. An Overview of the Tcl C Library
          1. Application Initialization
          2. Creating and Deleting Interpreters
          3. Creating and Deleting Commands
          4. Dynamic Loading and Packages
          5. Managing the Result String
          6. Memory Allocation
          7. Lists
          8. Command Parsing
          9. Command Pipelines
          10. Tracing the Actions of the Tcl Interpreter
          11. Evaluating Tcl Commands
          12. Reporting Script Errors
          13. Manipulating Tcl Variables
          14. Evaluating Expressions
          15. Converting Numbers
          16. Tcl Objects
          17. Primitive Object Types
          18. String Object Types
          19. ByteArrays for Binary Data
          20. Dynamic Strings
          21. Character Set Encodings
          22. AssocData for per Interpreter Data Structures
          23. Hash Tables
          24. Option Processing
          25. Regular Expressions and String Matching
          26. Event Loop Implementation
          27. File Handlers
          28. Timer Events
          29. Idle Callbacks
          30. Input/Output
          31. I/O Channel Drivers
          32. Manipulating File Names
          33. Examining the File System
          34. Virtual File System Implementations
          35. Thread Support
          36. Working with Signals
          37. Exit Handlers
          38. Macintosh
          39. Panic
          40. Miscellaneous
        2. An Overview of the Tk C Library
          1. Main Programs and Command-Line Arguments
          2. Creating Windows
          3. Application Name for Send
          4. Configuring Windows
          5. Command Options
          6. Window Coordinates
          7. Window Stacking Order
          8. Window Information
          9. Configuring Widget Attributes
          10. The Selection and Clipboard
          11. Event Loop Interface
          12. Handling Window Events
          13. Event Bindings
          14. Keyboard Grab
          15. Handling Graphic Protocol Errors
          16. Using the Resource Database
          17. Managing Bitmaps
          18. Creating New Image Types
          19. Using an Image in a Widget
          20. Photo Image Types
          21. Canvas Object Support
          22. Geometry Management
          23. String Identifiers (UIDS)
          24. Colors, Colormaps, and Visuals
          25. 3D Borders
          26. Mouse Cursors
          27. Fonts and Text Display
          28. Graphics Contexts
          29. Allocate a Pixmap
          30. Screen Measurements
          31. Relief Style
          32. Text Anchor Positions
          33. Line Cap Styles
          34. Line Join Styles
          35. Dashed Lines
          36. Text Justification Styles
          37. Atoms
          38. X Resource ID Management
          39. Windows Application Handles
    11. VII. Changes
      1. 51. Tcl 7.4/Tk 4.0
        1. wish
        2. Obsolete Features
        3. The cget Operation
        4. Input Focus Highlight
        5. Bindings
        6. Scrollbar Interface
        7. pack info
        8. Focus
        9. The send Command
        10. Internal Button Padding
        11. Radiobutton Value
        12. Entry Widget
        13. Menus
        14. Listboxes
        15. No geometry Attribute
        16. Text Widget
        17. Color Attributes
        18. Color Allocation and tk colormodel
        19. Canvas scrollincrement
        20. The Selection
        21. The bell Command
      2. 52. Tcl 7.5/Tk 4.1
        1. Cross-Platform Scripts
          1. File Name Manipulation
          2. Newline Translations
          3. The tcl_platform Variable
          4. The console Command
        2. The clock Command
        3. The load Command
        4. The package Command
        5. Multiple foreach loop variables
        6. Event Loop Moves from Tk to Tcl
        7. Network Sockets
          1. info hostname
          2. The fconfigure Command
        8. Multiple Interpreters and Safe-Tcl
        9. The grid Geometry Manager
        10. The Text Widget
        11. The Entry Widget
      3. 53. Tcl 7.6/Tk 4.2
        1. More file Operations
        2. Virtual Events
        3. Standard Dialogs
        4. New grid Geometry Manager
        5. Macintosh unsupported1 Command
      4. 54. Tcl/Tk 8.0
        1. The Tcl Compiler
          1. Compile-Time Errors
          2. Binary String Support
        2. Namespaces
        3. Safe-Tcl
        4. New lsort
        5. tcl_precision Variable
        6. Year 2000 Convention
        7. Http Package
        8. Serial Line I/O
        9. Platform-Independent Fonts
        10. The tk scaling Command
        11. Application Embedding
        12. Native Menus and Menubars
        13. CDE Border Width
        14. Native Buttons and Scrollbars
        15. Images in Text Widgets
        16. No Errors from destroy
        17. grid rowconfigure
        18. The Patch Releases
          1. fconfigure -error
          2. tcl_platform(debug)
          3. tcl_findLibrary
          4. auto_mkindex_old
          5. Windows Keysyms for Start and Menu Keys
          6. The MouseWheel Event
          7. Transparent Fill on Canvas Text
          8. safe::loadTk
      5. 55. Tcl/Tk 8.1
        1. Unicode and Internationalization
          1. fconfigure -encoding
          2. The encoding Command
          3. The msgcat Package
          4. UTF-8 and Unicode C API
        2. Thread Safety
          1. The testthread Command
        3. Advanced Regular Expressions
        4. New String Commands
        5. The DDE Extension
        6. Miscellaneous
          1. Serial Line I/O
          2. tcl_platform(user)
      6. 56. Tcl/Tk 8.2
        1. The Trf Patch
        2. Faster String Operations
        3. Empty Array Names
        4. Browser Plugin Compatibility
        5. Finer Control of Windows Serial Port Monitoring
        6. Regular Expression Expanded Syntax Option
      7. 57. Tcl/Tk 8.3
        1. New File Manipulation Commands and Options
        2. New glob Options
        3. Regular Expression Command Enhancements
        4. Direct Return of scan Matches
        5. Removing Duplicate List Elements with lsort
        6. Deleting Elements from an Array
        7. Enhanced clock Features
        8. Support for Delayed Package Loading in pkg_mkIndex
        9. The Img Patch
        10. The Dash Patch
          1. Canvas Improvements
          2. Hidden Text
          3. Pointer Warping
          4. Entry Widget Validation
        11. Other New Tk Features
          1. Listbox Enhancements
          2. New Directory Chooser Dialog
          3. Window Manager Interactions with Toplevel Windows
          4. Support Added for Windows System Cursors
          5. Mousewheel Support for Listbox and Text Widgets on Unix
          6. New Quadruple Event Modifier
          7. X Input Methods (XIM)
        12. The Patch Releases
          1. Detection of Entry Validation Type
          2. Macintosh File Selection Dialog Enhancement
          3. State Attributes for Label Widgets
          4. Support for Windows Icons
          5. New Reference Pages
      8. 58. Tcl/Tk 8.4
        1. 64-Bit Support
          1. 64-Bit Arithmetic
          2. 64-Bit Value Conversions
          3. 64-Bit Filesystem Support
          4. Native Word Size Detection
        2. Additional Filesystem Features and Commands
          1. Virtual Filesystems
          2. New file Subcommands and glob Options
        3. New and Enhanced List Commands
        4. Array Searching and Statistics
        5. Enhanced Support for Serial Communications
        6. New String Comparison Operators
        7. Command Tracing
        8. Additional Introspection Commands
        9. Other Tcl Changes
          1. Unsetting Nonexistent Variables
          2. Direct Return of Substituted String with regsub
          3. Increased Time Resolution on Windows
          4. Bug Fixed in fcopy to Respect Channel Encodings
        10. New Tk Widgets
        11. Text Widget Undo Mechanism and Other Enhancements
        12. New pack and grid Features
          1. Asymmetric Padding
          2. Uniform Rows and Columns in grid
        13. Displaying Both Text and an Image in a Widget
        14. New Button Relief Attributes
        15. Controlling the State of Entries and Listboxes
        16. More Window Manager Interaction
        17. Other Tk Changes
          1. Mouse Button Repeat Control
          2. Better Support for Image Transparency
          3. Selecting Multiple Files with tk_getOpenFile
          4. Fixed-Width Button Support on Windows Systems
          5. Easier Access to Clipboard Contents
          6. Determining if an Image is Used
          7. New Events and Substitutions for Window Managers
          8. Caret Management for Improved XIM/IME Support
          9. New bell Option to Prevent Resetting Screen Savers
          10. Generating Postscript for Embedded Widgets
      9. 59. About The CD-ROM
        1. Technical Support