Practical Programming in Tcl and Tk 2nd Ed.

Brent Welch

Publisher: Prentice Hall, 1997, 630 pages

ISBN: 0-13-616830-2

Keywords: TCLTk

Last modified: May 16, 2021, 11:35 p.m.

Completely-updated Tcl/Tk best-seller! Extensive new coverage of UNIX, Windows and Macintosh Tcl/Tk.

Authored by a member of the Tcl/Tk development team, Practical Programming in Tcl and Tk is the most comprehensive, practical guide to Tcl and Tk available. Beginners can rely on this book for a thorough, well-organized introduction—and experts will gain insight from the extensive programming tips and examples.

Tcl/Tk insider Brent Welch begins by introducing Tcl and the fundamental mechanisms that characterize it. It presents both basic and advanced coding techniques, describes Tcl's interface to the operating system, and the script library facility. He introduces Tk and the relevant aspects of graphical interface programming, presenting examples and sample widgets. Along the way, he shows experienced developers how Tcl and Tk have evolved—and how to take full advantage of its new capabilities.

You'll find extensive coverage of user interface development, including techniques for creating user interfaces that run on all major desktop platforms. Welch reviews Tcl's improved network support, as well as Safe Tcl and its recent enhancements. He also covers advanced topics such as C programming with the Tk toolkit. Finally, the book covers the new Tcl 8.0 compiler and the Tcl/Tk plug-in for both Netscape Navigator and Microsoft Explorer.

The accompanying CD-ROM includes all the source code in the book, plus an extensive library of Tcl/Tk and Tcl freeware for Windows 95, UNIX, Macintosh, Windows 3.1 and Windows NT.

Whether you're a current Tcl/Tk programmer, or a developer searching for a convenient, powerful multiplatform scripting language, Practical Programming in Tcl and Tk delivers exactly what you're looking for.

  1. Tcl Basics
    1. Tcl Fundamentals
      • Tcl Commands
      • Hello, World!
      • Variables
      • Command Substitution
      • Math Expressions
      • Backslash Substitution
      • Grouping with Braces and Double Quotes
        • Square Brackets Do Not Group
        • Grouping before Substitution
      • Procedures
      • A Factorial Example
      • More about Variables
        • Funny Variable Names
        • The unset Command
        • Using info to Find Out about Variables
      • More about Math Expressions
      • Comments
      • Substitution and Grouping Summary
      • Fine Points
      • Reference
        • Backslash Sequences
        • Arithmetlc Operators
        • Built-in Math Functions
        • Core Tcl Commands
    2. Getting Started
      • The source Command
      • UNIX Tcl Scripts
      • Windows 95 Start Menu
      • The Macintosh and ResEdit
      • The console Command
      • Command-Line Arguments
        • Command-Line Options to Wish
      • Predefined Variables
    3. The Guestbook CGI Application 
      • A Quick Introduction to HTML
      • CGI for Dynamic Pages
      • The guestbook.cgi Script
        • Beginning the HTML Page
        • Simple Tags and Hypertext Links
        • Using a Tcl Array for the Database
        • Sample Output
      • Defining Forms and Processing Form Data
        • The newguest.html Form
        • The newguest.cgi Script
      • Next Steps
    4. String Processing in Tcl
      • The string Command
      • Strings and Expressions
      • The append Command
      • The format Command
      • The scan Command
      • String Matching
      • The binary Command
        • Format Templates
        • Examples
      • Related Chapters
    5. Tcl Lists
      • Tcl Lists
      • Constructing Lists
        • The list command
        • The lappend Command
        • The concat Command
      • Getting List Elements: llength, lindex, and lrange
      • Seacrching Lists: linsert and lreplace
      • Sorting Lists: lsort
      • The split Command
      • The join Command
      • Related Chapters
    6. Control Structure Commands
      • If Then Else
      • Switch
        • Comments in switch Commands
      • While
      • Foreach
        • Multiple Loop Variables
        • Multiple Value Lists
      • For
      • Break and Continue
      • Catch
        • Catching More Than Errors
      • Error
      • Return
    7. Procedures and Scope
      • The proc Command
      • Changing Command Names with rename
      • Scope
      • The global Command
      • Call by Name Using upvar
      • Variable Aliases with upvar
        • Associating State with Data
        • Commands That Take Variable Names
    8. Tcl Arrays
      • Array Syntax
        • Complex Indices
        • Array Variables
      • The array Command
        • Converting Arrays to Lists
        • Passing Arrays by Name
      • Building Data Structures with Arrays
        • Simple Records
        • A Stack
        • A List of Arrays
    9. Working With Files and Programs
      • Running Programs with exec
        • The auto_noexec Variable
        • Limitations of exec on Windows
        • Limitations of exec on Macintosh
      • The file Command
      • Cross-Platform File Naming
        • Building up Pathnames: file join
        • Chopping Pathnames: split, dirname, tail
      • Manipulating Files and Directories
        • Copying Files
        • Creating Directories
        • Deleting Files
        • Renaming Files and Directories
      • File Attributes
      • Input/Output Command Summary
      • Opening Files for I/O
        • Opening a Process Pipeline
      • Reading and Writing
        • The puts and gets Commands
        • The read Command
        • Platform-Specific End of Line Characters
        • Random Access I/O
        • Closing I/O channels
      • The Current Directory — cd and pwd
      • Matching File Names with global
        • Expanding Tilde in File Names
      • The exit and pid Commands
      • Environment Variables
  2. Advanced Tcl
    1. Eval
      • Construct Commands with list
      • Exploiting the concat inside eval
        • Double Quotes and eval
        • More Examples
      • The uplevel Command
      • Commands That Concatenate Their Arguments
      • The subst Command
        • String Processing with subst
    2. Regular Expressions
      • Regular Expression Syntax
        • A Pattern to Match URLs
      • The regexp Command
      • Useful Regular Expressions
      • The regsub Command
      • Transforming Data to Tcl with regsub
        • URL Decoding
        • CGI Argument Parsing
        • Decoding HTML Entities
        • A Simple HTML Parser
        • Stripping HTML Comments
      • Other Commands That Use Regular Expressions
    3. Script Libraries and Packages
      • Locating Packages: The auto_path Variable
      • Using Packages
        • Loading Packages Automatically
        • Packages Implemented in C Code
      • The package Command
      • Libraries Based on the tclIndex File
      • The unkown Command
        • How Auto Loading Works
        • Disabling the Library Facility: auto_noload
      • Interactive Conveniences
        • Auto Execute
        • History
        • Abbreviations
      • Tcl Shell Library Environment
      • Coding Style
        • A Module Prefix for Procedure Names
        • A Global Array for State Variables
    4. Reflection and Debugging
      • The clock Command
      • The info Command
        • Variables
        • Procedures
        • The Call Stack
        • Command Evaluation
        • Scripts and the Library
        • Version Numbers
        • Execution Environment
      • Cross-Platform Support
      • Tracing Variable Values
      • Interactive Command History
        • History Syntax
        • A Comparison to C Shell History Syntax
      • Debugging
      • Don Libes' Debugger
        • Breakpoints by Pattern Matching
        • Deleting Break Points
      • Debugging Tk Scripts
        • The tkinspect Program
        • The tdebug Program
        • The bgerror Command
        • The tkerror Command
      • Performance Tuning
        • Time stamps in a Log
        • Tcl 8.0
    5. Namespaces
      • Using Namespaces
      • Qualified Names
        • Command Lookup
      • Nested Namespaces
      • Importing Procedures
      • Other Namespaces
      • Callbacks and Namespaces
      • Introspection
      • The namespace Command
      • Wrapping Existing Packages
      • [incr Tcl] Object System
      • Notes
        • AutoLoading
        • Namespaces and uplevel
        • Naming Quirks
        • Miscellaneous
    6. Event-Driven Programming
      • The Tcl Event Loop
      • The after Command
      • The fileevent Command
      • The vwait Command
      • The fconfigure Command
      • Non-Blocking I/O
      • The fblocked Command
      • Buffering End of Line Translations
      • End of File Character
      • Serial Devices
      • Configuring Read-Write Channels
    7. Socket Programming
      • Client Sockets
        • Client Socket Options
      • Server Sockets
        • Server Socket Options
      • The Echo Service
      • Fetching a URL with HTTP
        • Proxy Servers
        • The HEAD Request
        • The GET and POST Requests
        • The unsupported0 Command
        • The fcopy Command
      • The http Package
        • http_config
        • http_get
        • http_formatQuery
        • http_reset
    8. Multiple Interpreters and Safe-Tcl
      • The interp Command
      • Creating Interpreters
        • The Interpreter Hierachy
        • The Interpreter Name as a Command
        • Use list with interp eval
      • Safe Interpreters
      • Command Aliases
      • Alias Introspection
      • Hidden Commands
      • Substitutions
      • I/O from Safe Interpreters
      • The Safe Base
      • Security Policies
        • Limited Socket Access
        • Limited Temporary Files
        • Safe after Command
  3. Tk Basics
    1. Tk Fundamentals
      • Hello, World! in Tk
      • Naming Tk Widgets
      • Conflgunng Tk Widgets
      • Tk Widget Attributes and the Resource Database
        • The Tk Manual Pages
      • Summary of the Tk Commands
    2. Tk by Example
      • ExecLog
        • Window Title
        • A Frame for Buttons
        • Command Buttons
        • A Label and an Entry
        • Key Bindings and Focus
        • A Resizable Text and Scrollbar
        • The Run Procedure
        • The Log Procedure
        • The Stop Procedure
        • Cross-Platform Issues
      • The Example Browser
        • More about Resizing Windows
        • Managing Global State
        • Searching through Files
        • Cascaded Menus
        • A Read-Only Text Widget
      • A Tcl Shell
        • Text Marks, Tags, and Bindings
        • Multiple Interpreters
        • Native Look and Feel
    3. The Pack Geometry Manager
      • Packing toward a Side
        • Shrinking Frames and pack propagate
      • Horizontal and Vertical Stacking
      • The Cavity Model
      • Packing Space and Display Space
        • The -fill Option
        • Internal Padding with -ipadx and -ipady
        • External Padding with -padx and -pady
      • Resizing and -expand
      • Anchoring
      • Packing Order
        • Introspection
        • Pack the Scrollbar First
      • Choosing the Parent for Packing
      • Unpacking a Widget
      • Packer Summary
        • The pack Command
      • Window Stacking Order
    4. The Grid Geometry Manager
      • A Basic Grid
        • The -sticky Setting
        • External Padding with -padx and -pady
        • Internal Padding with -ipadx and -ipady
        • Multiple Widgets in a Cell
      • Spanning Rows and Columns
        • Row and Column Constraints
        • Row and Column Padding
        • Minimum Size
        • Managing Resize Behavior
        • The grid Command
    5. The Place Geometry Manager
      • place Basics
      • The Pane Manager
        • Parsing Arguments and Maintaining State
        • Sticky Geometry Settings
        • Event Bindings
        • Managing the Layout
      • The place Command
    6. Binding Commands to Events
      • The bind Command
      • The bindtags Command
        • Focus and Key Events
        • Using break and continue in Bindings
        • Defining New Binding Tags
        • Binding Precedence in Tk 3.6
      • Event Syntax
        • Keyboard Events
        • Detecting Modifiers in Tk 3.6 Mouse Events
        • Other Events
        • Bindings on Top-level Windows
      • Modifiers
        • Modifiers in Tk 3.6
      • Event Sequences
      • Virtual Events
      • Event Keywords
  4. Tk Widgets
    1. Buttons and Menus
      • Button Commands and Scope Issues
      • Butttons Associated with Tcl Variables
      • Button Attributes
      • Button Operations
      • Menus and Menubuttons
        • A Menu Bar
        • System Menus
        • Pop-up Menus
        • Option Menus
        • Multicolumn Palette Menus
      • Keyboard Traversal
      • Manipulating Menus and Menu Entries
      • Menu Attributes
      • A Menu by Name Package
        • Menu Accelerators
    2. The Resource Database
      • Introduction to Resources
        • Resource Patterns
      • Loading Option Database Files
      • Adding Individual Database Entries
      • Accessing the Database
      • User-Defined Buttons
      • User-Defined Menus
        • Application and User Resources
        • Expanding Variables
    3. Simple Tk Widgets
      • Frames and Toplevel Windows
        • Attributes for Frames and Toplevels
        • Embedding Other Applications
        • Toplevel Window Styles
      • The Label Widget
        • Label Width and Wrap Length
        • Label Attributes
      • The Message Widget
        • Message Attributes
        • Arranging Labels and Messages
      • The Scale Widget
        • Scale Bindings
        • Scale Attributes
        • Programming Scales
      • The bell Command
    4. Scrollbars
      • Using Scrollbars
      • The Scrollbar Protoco
      • l
        • The Scrollbar set Operation
        • The xview and yview Operations
        • The Tk 3.6 Protocol
      • The Scrollbar Widget
        • Scrollbar Bindings
        • Scrollbar Attributes
        • Programming Scrollbars
    5. The Entry Widget
      • Using Entry Widgets
        • Tips for Using Entry Widgets
      • The Entry Widget
        • Entry Attributes
        • Programming Entry Widgets
    6. The Listbox Widget
      • Using Listboxes
        • Programming Listboxes
      • Listbox Bindings
        • Browse Select Mode
        • Single Select Mode
        • Extended Select Mode
        • Multiple Select Mode
        • Scroll Bindings
      • Listbox Attributes
        • Geometry Gridding
    7. The Text Widget
      • Text Indices
        • Inserting and Deleting Text
        • Index Arithmetic
        • Comparing Indices
      • Text Marks
        • Mark Gravity
      • Text Tags
        • Tag Attributes
        • Mixing Attributes from Different Tags
        • Line Spacing and Justification
        • Tab stops
      • The Selection
      • Tag Bindings
      • Searching Text
      • Embedded Widgets
      • Embedded Images
      • Looking inside the Text Widget
        • Looking at Tags
        • Looking at Marks
        • Dumping the Contents
      • Text Bindings
      • Text Operations
      • Text Attributes
    8. The Canvas Widget
      • Canvas Coordinates
      • Hello, World!
        • Canvas Tags
      • The Min Max Scale Example
      • Canvas Objects
        • Arc Items
        • Bitmap Items
        • Image Items
        • Line Items
        • Oval Items
        • Polygon Items
        • Rectangle Items
        • Text Items
        • Window Items
      • Canvas Operations
      • Generating Postscripts
      • Canvas Attributes
      • Hints
        • Screen Coordinates vs Canvas Coordinates
        • Large Coordinate Spaces
        • Scaling and Rotation
        • Resources
        • Objects with Many Points
        • Selecting Canvas Items
  5. Tk Details
    1. Selections and the Clipboard
      • The Selection Model
      • The selection Command
      • The clipboard Command
      • Selection Handlers
        • A Canvas Selection Handler
    2. Focus, Grabs, and Dialogs
      • Standard Dialogs
        • Message Box
        • File Dialogs
        • Color Dialog
      • Custom Dialogs
        • Input Focus
        • The focus Command
        • Keyboard Focus Traversal
        • Grabbing the Focus
        • The tkwait Command
        • Destroying Widgets
        • The focus, grab, tkwait sequence
        • Prompter Dialog
        • Keyboard Shortcuts and Focus
      • Animation with the update Command
    3. Tk Widget Attributes
      • Configuring Attributes
      • Size
      • Borders and Relief
      • The Focus Highlight
      • Padding and Anchors
        • Putting It All Together
    4. Color, Images, and Cursors
      • Colors
        • Color Palettes
        • Color Values
      • Colormaps and Visuals
      • Bitmaps and Images
        • The image Command
        • Bitmap Images
        • The bitmap Attribute
        • Photo Images
      • The Text Insert Cursor
      • The Mouse Cursor
    5. Fonts and Text Attributes
      • Naming a Font
        • Named Fonts
        • System Fonts
      • X Font Names
        • Font Failures before Tk 80
      • Font Metrics
      • The font Command
      • Text Attributes
        • Layout
        • Selection Attributes
      • Gridding, Resizing, and Geometry
      • A Font Selection Application
    6. Send
      • The send Command
        • Send and X Authority
      • The Sender Script
      • Communicating Processes
      • Remote eval through
      • Sockets
    7. Window Managers and Window Information
      • The wm Command
        • Size, Placement, and Decoration
        • Icons
        • Session State
        • Miscellaneous
      • The winfo Command
        • Sending Commands between
        • Applications
        • Family Relationships
        • Size
        • Location
        • Virtual Root Window
        • Atoms and IDs
        • Colormaps and Visuals
      • The tk Command
    8. Managing User Preferences
      • App-Defaults Files
      • Defining Preferences
      • The Preferences User Interface
      • Managing the Preference File
      • Tracing Changes to Preference Variables
      • Improving the Package
    9. A User Interface to Bindings
      • A Pair of Listboxes Working Together
      • The Editing Interface
      • Saving and Loading Bindings
  6. C Programming
    1. C Programming and Tcl
        • Using the Tcl C Library
      • Application Structure
      • Creating a Loadable Package
        • The load Command
        • Using Tcl_PkgProvide
      • A C Command Procedure
        • The String Command Interface
        • Managing String Result
        • The Object Command Interface
        • Managing Object Reference Counts
      • Tcl_Main and Tcl_AppInit
        • Tk_Main
      • The Event Loop
      • Invoking Scripts from C
        • Bypassing Tcl_Eval
      • Expect's Tcl Debugger
        • The Dbg C Interface
        • Handling SIGINT
      • Putting a Tcl Program Together
        • A Simple UNIX Example
        • Autoconf
        • Windows
        • Macintosh
    2. C Librarv Overview
      • An Overview of the Tcl C Library
        • Application Initialization
        • Creating and Deleting Interpreters
        • Creating and Deleting Commands
        • Dynamic Loading and Packages
        • Managing the Result String
        • Memory Allocation
        • Lists and Command Parsing
        • Command Pipelines
        • Tracing the Actions of the Tcl Interpreter
        • Evaluating Tcl Commands
        • Reporting Script Errors
        • Manipulating Tcl Variables
        • Evaluating Expressions
        • Converting Numbers
        • Tcl Objects
        • Primitive Object Types
        • String Keys for Data Structures
        • Option Processing
        • Hash Tables
        • Dynamic Strings
        • Regular Expressions and String Matching
        • Event Loop Interface
        • Handling Window Events
        • File Handlers
        • Timer Events
        • Idle Callbacks
        • Sleeping
        • Event Loop Implementation
        • Input/Output
        • I/O Channel Drivers
        • Manipulating File Names
        • Working with Signals
        • Exit Handlers
      • An Overview of the Tk C Library
        • Parsing Command-Line Arguments
        • The Standard Application Setup
        • Creating Windows
        • Application Name for Send
        • Configuring Windows
        • Window Coordinates
        • Window Stacking Order
        • Window Information
        • Configuring Widget Attributes
        • Safe Handling of the Widget Data Structure
        • The Selection and Clipboard
        • Event Bindings
        • Handling Graphic Protocol Errors
        • Using the Resource
        • Database
        • Managing Bitmaps
        • Creating New Image Types
        • Using an Image in a Widget
        • Photo Image Types
        • Canvas Object Support
        • Geometry management
        • String Identifiers (UIDS)
        • Colors, Colormaps, and Visuals
        • 3D Borders
        • Mouse Cursors
        • Fonts and Text Display
        • Graphics Contexts
        • Allocate a Pixmap
        • Screen Measurements
        • Relief Style
        • Text Anchor Positions
        • Line Cap Styles
        • Line Join Styles
        • Text Justification Styles
        • Atoms
        • X Resource ID Management
    3. Writing a Tk Widget in C
      • The Widget Data Structure
      • The Widget Class Command
      • The Widget Instance Command
      • Configuring and Reconfiguring Attributes
      • Specifying Widget Attributes
      • Displaying the Clock
      • The Window Event Procedure
      • Final Cleanup
  7. Changes
    1. Tcl 7.4/Tk 4.0
      • wish
      • Obsolete Features
      • The cget Operation
      • Input Focus Highlight
      • Bindings
      • Scrollbar Interface
      • pack info
      • Focus
      • The send Command
      • Internal Button Padding
      • Radiobutton Value
      • Entry Widget
      • Menus
      • Listboxes
      • No geometry Attribute
      • Text Widget
      • Color Attributes
      • Color Allocation and tk colormodel
      • Canvas scrollincrement
      • The Selection
      • The bell Command
    2. Tcl 7.5/Tk 4.1
      • Cross-Platform Scripts
        • File Name Manipulation
        • Newline Translations
        • The tcl_platform Variable
        • The console Command
      • The clock Command
      • The load Command
      • The package Command
      • Multiple foreach loop variables
      • Event Loop Moves from Tk to Tcl
      • Network Sockets
        • info hostname
        • The fconfigure Command
      • Multiple Interpreters and Safe-Tcl
      • The grid Geometry Manager
      • The Text Widget
      • The Entry Widget
    3. Tcl 7.6/Tk 4.2
      • More file Operations
      • Virtual Events
      • Standard Dialogs
      • New grid Geometry Manager
      • Macintosh unsupported1 Command
    4. Tcl/Tk 8.0
      • The Tcl Compiler
        • Compile-Time Errors
        • Binary String Support
      • Namespaces
      • Safe-Tcl
      • New lsort
      • No tcl_precision Variable
      • Year 2000 Convention
      • Http Package
      • Serial Line I/O
      • Platform-Independent Fonts
      • The tk scale Command
      • Application Embedding
      • Native Menus and Menubars
      • CDE Border Width
      • Native Buttons and Scrollbars
      • Images in Text Widgets
      • No Errors from destroy
      • grid rowconfigure
      • Late Breaking News
    5. Safe-Tk and the Browser Plug-In
      • Tk in Child Interpreters
        • Embedding Tk Windows
        • Safe-Tk Restrictions
      • The Browser Plug-In
        • Setting Up the Plug-In
        • UNIX Configuration
        • Windows Configuration
        • Macintosh Configuration
      • Security Policies and Browser Plug-in
        • The Browser Package
        • Configuring Security Policies
      • Notes

Reviews

Practical Programming in Tcl and Tk

Reviewed by Roland Buresund

Very Good ******** (8 out of 10)

Last modified: Nov. 18, 2008, 2:18 p.m.

A very good book on programming in Tcl/Tk.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required