Tcl/Tk

Tcl/Tk

A Developer's Guide

2nd Edition - May 5, 2003

Write a review

  • Authors: Clif Flynt, Marshall Rose
  • eBook ISBN: 9780080518435

Purchase options

Purchase options
DRM-free (PDF)
Sales tax will be calculated at check-out

Institutional Subscription

Free Global Shipping
No minimum order

Description

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.

Key Features

*Brings beginners up to speed quickly.
*Overview of Tcl development tools, popular extensions, and packages.
*Tips, style guidelines, and debugging techniques for the advanced user.

Readership

Programmers, Internet designers, and open source programmers.

Table of Contents

  • Tcl/Tk Features.
    1.1 Tcl Overview.
    1.1.1 The Standard Tcl Distribution
    1.2 Tcl as a Glue Language
    1.2.2 Tcl Scripts Compared with Unix Shell Scripts
    1.2.3 Tcl Scripts Compared with MS-DOS .bat Files
    1.3 Tcl as a General-Purpose Interpreter
    1.3.1 Tcl/Tk Compared with Visual Basic
    1.3.2 Tcl/Tk Compared with Perl
    1.3.3 Tcl/Tk Compared with Python
    1.3.4 Tcl/Tk Compared with Java
    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

    The Mechanics of Using the Tcl and Tk Interpreters.
    2.1 The tclsh and wish Interpreters
    2.1.1 Starting the tclsh and wish Interpreters
    2.1.2 Starting tclsh or wish under Unix
    2.1.3 Starting tclsh or wish under Microsoft Windows
    2.1.4 Starting tclsh or wish on the Mac
    2.1.5 Exiting tclsh or wish
    2.2 Using tclsh/wish Interactively
    2.2.1 Tclsh as a Command Shell
    2.2.2 Tk Console (tkcon) -- An Alternative Interactive tclsh/wish Shell
    2.2.3 Evaluating Scripts Interactively
    2.3 Evaluating Tcl Script Files
    2.3.1 The Tcl Script File
    2.3.2 Evaluating Tcl Script Files
    2.3.3 Evaluating a Tcl Script File under Unix
    2.3.4 Evaluating a Tcl Script File under Microsoft Windows
    2.3.5 Evaluating a Tcl Script on the Mac
    2.4 Bottom Line
    2.5 Problems

    Introduction to the Tcl Language.
    3.1 Overview of the Basics
    3.1.1 Syntax
    3.1.2 Grouping Words
    3.1.3 Comments
    3.1.4 Data Representation
    3.1.5 Command Results
    3.1.6 Errors
    3.2 Command Evaluation and Substitutions
    3.2.1 Substitution
    3.2.2 Controlling Substitutions with Quotes, Curly Braces, and Backslash
    3.2.3 Steps in Command Evaluation
    3.3 Data Types
    3.3.1 Assigning Values to Variables
    3.3.2 Strings
    3.3.3 String Processing Commands
    3.3.4 Lists
    3.3.5 List Processing Commands
    3.3.6 Associative Arrays
    3.3.7 Associative Array Commands
    3.3.8 Binary Data
    3.3.9 Handles
    3.4 Arithmetic and Boolean operations
    3.4.1 Math Operations
    3.4.2 Conditionals
    3.4.3 Looping
    3.5 Modularization
    3.5.1 Procedures
    3.6 Bottom Line
    3.7 Problems

    File System, Disk I/O and Sockets.
    4.0.1 Navigating the File System
    4.0.2 Properties of file system items
    4.0.3 Removing files
    4.1.2 Input
    4.1.3 Creating a channel
    4.1.4 Closing Channels
    4.1 Input/Output in Tcl
    4.1.1 Output
    4.2 Sockets
    4.2.1 Using a client socket
    4.2.2 Controlling Data Flow
    4.2.3 Server Sockets
    4.3 Bottom Line
    4.4 Problems

    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 the string match instead of string first
    5.5 Using lsearch
    5.6 The regexp Command
    5.6.1 Regular Expression Matching Rules
    5.6.2 Advanced and Extended Regular Expression Rules
    5.7 Creating a Procedure
    5.8 Making a Script
    5.9 Speed Considerations
    5.10 Bottom Line
    5.11 Problems

    Building complex data structures with lists and arrays.
    6.1 Using the Tcl List
    6.2 Using the Associative Array
    6.3 Exception handling and Introspection
    6.4 Trees in Tcl
    6.5 Tree Library Implementation
    6.5.5 Generating unique names
    6.6 Using the Tree Library
    6.7 Speed Considerations
    6.8 Bottom Line
    6.9 Problems

    Procedure Techniques.
    7.1 Arguments to Procedures
    7.1.1 Variable Number of Arguments to a Procedure
    7.1.2 Default Values for Procedure Arguments
    7.2 Renaming or Deleting Commands
    7.3 Getting Information about Procedures
    7.4 Substitution and Evaluation of Strings
    7.4.1 Performing Variable Substitution on a String
    7.4.2 Evaluating a String as a Tcl Command
    7.5 Working with Global and Local Scopes
    7.5.1 Global and Local Scope
    7.6.1 An Object Example
    7.6.2 Creating a Tree Object
    7.6.3 Defining the Object's Method
    7.6 Making a Tcl Object
    7.7 Bottom Line
    7.8 Problems

    Namespaces and Pack.
    8.1 Namespaces and Scoping Rules
    8.1.1 Namespace Scope
    8.1.2 Namespace Naming Rules
    8.1.3 Accessing Namespace Entities
    8.1.4 Why Use Namespaces?
    8.1.5 The namespace and variable Commands
    8.1.6 Creating and Populating a Namespace
    8.1.7 Namespace Nesting
    8.2 Packages
    8.2.1 How Packages Work
    8.2.2 Internal Details: Files and Variables Used with Packages
    8.2.3 Package Commands
    8.2.4 Version Numbers
    8.2.5 Package Cookbook
    8.3 A Tree Object Package with Namespaces
    8.3.1 Adding Namespace and Package to tree.tcl
    8.3.2 The Tree Object in a Namespace
    8.3.3 Procedures and Namespace Scopes
    8.4 Bottom Line
    8.5 Problems

    Introduction to Tk Graphics.
    9.1 Creating a Widget
    9.2 Conventions
    9.2.1 Widget Naming Conventions
    9.2.2 Color Naming Conventions
    9.2.3 Dimension Conventions
    9.3 Common
    9.4 Determining and Setting Options
    9.5 The Basic Widgets
    9.6 Introducing Widgets: label, button, and entry
    9.7 Widget Layout: frame, place, pack, and grid
    9.7.1 The frame Widget
    9.7.2 The place Layout Manager
    9.7.3 The pack Layout Manager
    9.7.4 The grid Layout Manager
    9.7.5 Working Together
    9.8 Selection Widgets: radiobutton, checkbutton, menu, and listbox
    9.8.1 radiobutton and checkbutton
    9.8.2 Pull-down Menus: menu, menubutton and menubars
    9.8.2.1 Menubars
    9.8.3 Selection widgets: listbox
    9.9 Scrollbar
    9.9.1 The Basic scrollbar
    9.9.2 scrollbar Details
    9.9.3 Intercepting scrollbar Commands
    9.13.1 Canceling the Future
    9.10 The scale Widget
    9.11 New Windows
    9.12 Interacting with the Event Loop
    9.13 Scheduling the Future: after
    9.14 Bottom Line
    9.15 Problems

    Using the canvas widget.
    10.1 Overview of the canvas Widget
    10.1.1 Identifiers and Tags
    10.1.2 Coordinates
    10.1.3 Binding
    10.2 Creating a canvas
    10.3 Creating Displayable Canvas Items
    10.3.1 An Exam
    10.4 More Canvas Widget Subcommands
    10.4.1 Modifying an Item
    10.4.2 Changing the Display Coordinates of an Item
    10.4.3 Moving an Item
    10.4.4 Finding Items, Raising and Lowering Items
    10.4.5 Fonts and Text items
    10.4.6 Using a Canvas Larger than the View
    10.5 The bind and focus Commands
    10.5.1 The bind Command
    10.5.2 The Canvas Widget bind Subcommand
    10.5.3 Focus
    10.6 Creating a Widget
    10.7 A Help-Balloon: Interacting with the window manager
    10.8 The image Object
    10.8.1 The image Command
    10.8.2 Bitmap Images
    10.8.3 Photo Images
    10.8.4 Revisiting the delayButton Widget
    10.9 Bottom Line
    10.10 Problems

    The text widget and htmllib.
    11.1 Overview of the text Widget
    11.1.1 Text Location in the text Widget
    11.1.2 Tag Overview
    11.1.3 Mark Overview
    11.1.4 Image Overview
    11.1.5 Window Overview
    11.2 Creating a text Widget
    11.3 Text Widget Subcommands
    11.3.1 Inserting and deleting text
    11.3.2 Searching Text
    11.3.3 The mark Subcommands
    11.3.4 Tags
    11.3.4.2 Finding Tags
    11.3.5 Inserting Images and Widgets into a text Widget
    11.4 HTML Display Package
    11.4.1 Displaying HTML Text
    11.4.2 Using html_library Callbacks: Loading Images and Hypertext Links
    11.4.3 Interactive help with the text widget and htmllib
    11.5 Bottom Line
    11.6 Problems

    Tk Megawidgets.
    12.1 Standard Dialog Widgets
    12.2 Megawidget Building Philosophy
    12.2.1 Display in Application Window or Main Display?
    12.2.2 Modal versus Modeless Operation
    12.2.3 Widget Access Conventions
    12.2.4 Widget Frames
    12.2.5 Configuration
    12.2.6 Access to Subwidgets
    12.2.7 Following Tk Conventions
    12.3 Functionality that makes Megawidgets possible
    12.3.1 The rename command
    12.3.2 The option command
    12.3.3 The -class option
    12.4 Building a Megawidget
    12.5 A Scrolling Listbox Megawidget
    12.5.1 scrolledListBox Description
    12.5.2 Using the scrolledLB
    12.5.3 Implementing the Scrollable ListBox
    12.5.4 The scrolledLB Code
    12.6 Namespaces and Tk widgets
    12.7 Incorporating a Megawidget into a Larger Megawidget
    12.8 Making a Modal Megawidget: The grab and tkwait Commands
    12.8.1 The grab command
    12.8.2 The tkwait command
    12.8.3 The modal widget code
    12.9 Automating megawidget Construction
    12.9.1 Building megawidgets from a skeleton
    12.9.2 Building megawidgets from a configuration file
    12.9.3 Another technique for building megawidgets
    12.10 Bottom Line
    12.11 Problems

    Writing a Tcl Extension.
    13.1 Functional View of a Tcl Extension
    13.1.1 Overview
    13.1.2 Initialize any persistent data structures
    13.1.3 Register new commands with the Interpreter
    13.1.4 Accept data from Tcl Interpreter
    13.1.5 Returning Results
    13.1.6 Returning Status to the Script
    13.1.7 Dealing with Persistent Data
    13.2 Building an Extension
    13.2.1 Structural Overview of an Extension
    13.2.2 Naming Conventions
    13.3 An Example
    13.3.1 demoInt.h
    13.3.2 demoInit.c
    13.3.3 demoCmd.c
    13.3.4 demoDemo.c
    13.4 Complex Data
    13.5 Bottom Line
    13.6 Exercises

    Extensions and Package.
    14.1 [incr Tcl]
    14.2 Expect
    14.3 TclX
    14.4 Sybtcl and Oratcl
    14.5 MySqlTcl
    14.6 VSdb Package
    14.7 BWidgets
    14.8 BLT
    14.9 Graphics Extensions: Img
    14.10 Bottom Line

    Programming Tools.
    15.1 Code Formatter
    15.1.1 frink
    15.2 Code Checkers
    15.2.1 tclCheck
    15.2.2 ICEM ice_lint
    15.2.3 procheck
    15.3 Debuggers
    15.3.1 Debug
    15.3.2 Graphic Debuggers
    15.4 GUI Generators
    15.4.1 SpecTcl
    15.4.2 Visual GYPSY
    15.5 Tcl Compilers
    15.5.1 ICEM Tcl Compiler
    15.5.2 TclPro procomp
    15.6 Packaging Tools
    15.6.1 TclPro prowrap
    15.6.2 FreeWrap
    15.6.3 Starkit and Starpack
    15.7 Tcl Extension Generators
    15.7.1 SWIG
    15.7.2 CriTcl
    15.8 Integrated Development Environments
    15.8.1 ASED
    15.8.2 Komodo
    15.8.3 MyrmecoX
    15.9 Bottom Line

    Tips and Techniques.
    16.1 Debugging Techniques
    16.2 Tcl as a Glue Language: The exec Command
    16.3 Common Mistakes
    16.4 Coding Tips and Techniques
    16.5 Bottom Line

Product details

  • No. of pages: 758
  • Language: English
  • Copyright: © Morgan Kaufmann 2003
  • Published: May 5, 2003
  • Imprint: Morgan Kaufmann
  • eBook ISBN: 9780080518435

About the Authors

Clif Flynt

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

Marshall Rose

Affiliations and Expertise

Dover Beach Consulting, Inc., Mountain View, California, U.S.A.

Ratings and Reviews

Write a review

There are currently no reviews for "Tcl/Tk"