Graphical Applications with Tcl & Tk

Eric F. Johnson

Publisher: M&T, 1996, 374 pages

ISBN: 1-55851-471-6

Keywords: TCLTk

Last modified: July 20, 2021, 6:11 p.m.

Tcl, the Tool Command Language, has captured the hearts and minds of tens of thousands of software developers worldwide. It's an easy-to-learn scripting language that runs under Windows, UNIX, and Macintosh. Best of all, it's free. An associated toolkit called Tk allows you to quickly create graphical applications that can run on multiple platforms without delving into arcane subjects like Win32, QuickDraw, Object Linking and Embedding, Motif, and the X Toolkit Intrinsics.

With a surprisingly small amount of code, you'll soon be creating cross-platform graphical applications. Graphical Applications with Tcl and Tk will teach you the basics of the syntax and show you how to start writing menus, opening dialog boxes, and loading GIF images. With a focus on portable cross-platform scripts, user interface style guides, and clear, practical examples, this book allows you to get the most out of Tcl/Tk.

    • Introduction
      • What Is Tcl?
      • When to Use Tcl
  • Section I: Writing Applications in Tcl/Tk
    1. Your First Tcl Programs
      • What is a Tcl Program?
        • Make-a-Wish
      • A First Tcl Program
      • The First Commands in Depth
        • Widget Names
        • Button Options
      • Looking up Information on Tcl and Tk Commands
      • The Pack Command
      • Making a Tcl Script from Our Commands
        • What Happens If You Try This from tclsh?
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    2. Tcl Basics
      • Tcl Syntax
      • Tcl Variables
        • Variables and Substitutions
      • Command Substitution
      • Changing Data in Variables
      • Array Variables
        • Searching through Arrays
        • Emulating Multidimensional Arrays
      • Special Arrays for Environmental Variables
      • Special Arrays to Describe Your Computing Platform
      • Controlling the Flow of the Script
      • Expressions
      • Better to Switch than Fight
        • More Example Globe
        • Regex Matches
        • The regexp Command
        • Using -regexp in the switch Command
        • The regsub Command
      • Looping Commands
      • Jumping Out of Things
      • Built-In Procedures in Tcl
      • Writing Your Own Procedures
      • Call by Reference
        • Renaming Procedures
        • Procedures with a Variable Number of Arguments
      • Math in Tcl
        • Numerical Notation
        • Math Procedures
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    3. Interacting with the User
      • The Tour de Widgets
      • Pushing Buttons
        • Creating Widgets
        • Common Widget Options
        • Widget Examples
        • Colored Buttons
      • Color Names
        • RGB Colors
      • Fonts
        • Coming Up with Font Names
        • Wildcards in Font Names
        • Text Options
      • Changing Widgets Once Created
      • Displaying Text Messages with Labels
      • Multiline Labels
      • Framing Widgets
      • Radio and Check buttons
        • Radiobuttons
        • Flashing Radiobuttons
      • The Scale Widget
        • Controlling the Scale
        • Controlling Floating-Point Conversions
        • Executing Tcl Code When the Scale Changes
        • Making Scale Widget Commands
        • Special Scale Widget Commands
        • RGB Scales
      • How the Widget Packer Works
        • Inserting Widgets into the Layout
        • Filler Up
        • Padding
      • Finding Out about the Packer
        • Placing Widgets
      • Destroying widgets
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    4. Menus
      • Creating Menus
      • Menubuttons Pull-Down Menus
      • Populating Menus with Menu Choices
      • Cascading Submenus
      • Tear-Off Menu
      • Making Menu Bars
      • Keyboard Shortcuts and Accelerators
      • Binding Events to Call Tcl Scripts
        • Binding Mouse Events
        • Class Bindings
        • Getting at Event Data in the Tcl Script
        • Bindings for Accelerators and Keyboard Shortcuts
      • Standard Menus
        • The File Menu
        • The Edit Menu
        • The View Menu
        • The Options Menu
        • The Help Menu
        • Placing the Help Menu
      • The Main Window
      • Option Menus
      • Pop-up Menus
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    5. Text Editing with Tcl and Tk
      • Entering Text
      • Creating Entry Widgets
        • Password Entry
        • Deleting All Text in an Entry Widget
        • The Insertion Cursor
        • Entry Widget Selections
        • Scrolling in the Entry Widget
      • Multiline Text Widgets
        • Controlling the Text Widget Display
        • Deleting Text
        • Defining Positions in the Text
        • Inserting Text
        • Searching Through the Text
        • Retrieving Text
      • Marks, Tags and Embedded Windows
        • Marks
        • Using Tags to Control Fonts
        • Embedded Windows
        • Making Hypertext Links in the Text
        • Disabling Widgets
      • Cut, Copy, and Paste with the Text Widget
        • The Clipboard
        • The Clipboard and the Selection
        • Getting the Selected Text
        • Putting Text in the Clipboard
        • Clearing Text in the Clipboard
        • Retrieving Data from the Clipboard
        • Copy
        • Cut
        • Paste
        • Text Widget Efficiency
      • Connecting the Text Widget to a Scrollbar
      • Tcl String-Handling Commands
        • Extracting Substrings
        • Comparing Strings
        • Searching in Strings
        • Changing Case
        • Trimming Strings
      • A Tcl-Based Text Editor
        • Executing Tcl Scripts within Tcl
        • Creating the Script
      • Summary
        • Tcl/Tk Commands Covered in this Chapter
    6. Lists, Files, and Directories
      • Lists
        • Building Lists
        • Inserting Elements into a List
        • Appending Elements to a List
        • Pulling Out Elements from a List
        • Breaking Up Lists
        • Searching Through Lists
        • Sorting Lists
      • Special Lists for Accessing the Command Line
      • Listbox Widgets
        • Connecting a Listbox to a Scrollbar
        • Listbox Indices
        • List Anchars
        • Accessing Listbox Items
        • Finding Out which Items Are Selected
        • Making an Item Visible
        • Listbox Examples
        • A Multicolumn List
      • Accessing Files
        • Built-In File IDs
        • Reading a File Line By Line
        • Seeking Data in Files
        • Reading a File Into a Text Widget
        • Saving the Contents of a Text Widget to Disk
      • Scanning Directories
        • Changing Directories
      • A Tcl Directory Browser
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    7. Dialog Windows
      • Dialog Windows
      • Modal and Nonmodal Windows
        • Convenience Dialog Windows
      • Building Your Own Dialog Windows
        • Creating Top-Level Application Windows
        • Setting Window Manager Options
        • Positioning Dialog Windows
      • Handling the Close Window Manager Option
      • Building Your Own Convenience Dialog Windows
        • Error Dialog Windows
        • File Open and Save Dialog Windows
      • Drop-Down Lists
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
  • Section II: Advanced Applications
    1. Tcl Tricks and Traps: Handling Errors and Debugging
      • Handling Errors
        • Handling Background Errors with tkerror
        • Reporting Errors in Your Code
        • Setting Error Data
        • Building a New tkerror Procedure
        • Catching Errors with Catch
        • The Great Unknown
      • Debugging Tcl Applications
        • Debugging with tkerror
        • Tracing the Execution of Tcl Scripts for Debugging
        • Finding Out More about the State of the Tcl Interpreter
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    2. The Canvas Widget, Bitmaps, and Images
      • The Canvas Widget
        • Creating Drawing Items in the Canvas Widget
        • Scrolling the Canvas Widget
        • Manipulating Canvas Items
        • Binding Events to Canvas Drawing Items
        • Generating PostScript Output
      • Images and Bitmaps
        • Image Names
        • Built-In Bitmaps
        • Photo Images
        • Displaying Thumbnail Images
        • Deleting Images
        • Querying Images
      • The Main Window Revisited
        • Creating Toolbars
        • Help on Toolbars
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    3. Launching Applications from Tcl
      • Executing Commands
        • Tricks of Combining Eval with Exec
      • Standard Input, Output, and Error
        • Redirecting Input and Output in Commands
      • Pipes
      • Executing Tcl Scripts from within Tcl
      • Executing Scripts After a Time-Out
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    4. Embedding Tcl in Your Applications
      • Calling Tcl from C
        • When to Code in Tcl and When to Code in C
      • The Simplest Tcl Interpreter
        • Compiling and Linking Your New Interpreter
        • Running the Example Interpreter
      • Creating More Complex Applications
      • Adding in Tk into Your Programs
        • Linking with Tk
        • Running the tkapp Program with Tk
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    5. Extending Tcl
      • Making New Commands
      • Creating Your New Tcl Commands
        • Returning a Result
        • Returning an Error
        • Accessing Tcl Variables in Your Commands
        • Allocating Text Strings
        • Converting Strings
        • Evaluating Arguments
        • Looking Up Objects
      • Registering New Commands with the Interpreter
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
    6. Advanced Applications
      • Finishing the Application
        • Setting up an Icon
        • Cursors
        • Color Schemes
        • Updating Widgets
      • Sending Commands to Applications
        • Security Issues with Send
      • Cross-Platform Issues
        • The Option Database
      • The Future of Tcl and Tk
      • Summary
        • Tcl/Tk Commands Introduced in this Chapter
  • Appendix A: For More Information
    • Tcl/Tk Books
    • UNIX Books
    • X Window System Books
    • Tcl Information and Code on the Internet
      • Usenet News
  • Appendix B: Installing Tcl and Tk
    • Installing Tcl and Tk on UNIX
      • What You Need
      • Installing Tcl on UNIX
      • Installing Tk on UNIX
      • Cleaning Up after the Installation
    • Installing Tcl and Tk on Windows NT, Windows 95 or Windows 3.1
      • Installing the Binary Version
      • Compiling from Source Code
  • Appendix C: The CD-ROM

Reviews

Graphical Applications with Tcl/Tk

Reviewed by Roland Buresund

Disappointing *** (3 out of 10)

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

A very simplistic primer.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required