Effective Tcl/Tk Programming

Writing Better Porgrams with Tcl and Tk

Mark Harrison, Michael McLennan

Publisher: Addison-Wesley, 1998, 405 pages

ISBN: 0-201-63474-0

Keywords: Programming, TCLTk

Last modified: July 28, 2021, 8:18 a.m.

You need a graphical user interface, and it needs to run on multiple platforms. You don't have much time, and you're not a wizard with X/Motif, the Win32 GUI, or the Mac GUI. The project seems impossible, but with Tcl/Tk it's simple and fun.

The Tcl scipting language and the Tk toolkit create a powerful programming environment for building graphical user interfaces. With two lines of code, you can create a simple button; with two hundred lines of code, a desktop calculator, and with a thousand lines of code, and industrial-strength groupware calendar and appointment minder. Your applications run on all of the major platforms: UNIX, Windows 95/NT, and Macintosh. You can even embed your program in a Web page to make them available online.

Ideal for developers who are acquainted with the basics of Tcl/Tk and are now moving on to build real applications, Effective Tcl/Tk Programming shows you how to build Tcl/Tk applications effectively and efficiently through plenty of real-world advice. The authors clarify some of the more powerful aspects of Tcl/Tk, such as the packer, the canvas widget, and binding tags. The book describes valuable design strategies and coding techniques that will make your Tcl/Tk projects successful. You will learn how to:

  • Create interactive displays with the canvas widget
  • Create customized editors with the text widget
  • Create new geometry managers, like tabbed notebooks or paned windows
  • Implement client/server architectures
  • Handle data structures
  • Interface with existing applications
  • Package Tcl/Tk code into reusable libraries
  • Deliver Tcl/Tk applications that are easy to configure and install
  • Embed applications in a Web page
  • Build applications that will run on multiple platforms

Throughout the book the authors develop numerous applications and a library of reusable components. Learn from their approach, follow their strategies, and steal their code for your own applications! But don't bother retyping all of the examples. You can download all the source code at the Effective Tcl/Tk Programming Web site.

  1. Building Tcl/Tk Applications
    1. Application-building process
    2. A small application
      1. Designing the application
      2. Designing the screen
      3. Prototyping the screen
      4. Library analysis
      5. Adding behavior to the program
      6. Adding finishing touches
      7. Testing the program
      8. Packaging the program
  2. Packing, Gridding, and Placing Windows
    1. Using the pack command
      1. Cavity-based model
      2. Packingg options
      3. Packing order
      4. Hierarchical packing
      5. Compressing windows
      6. Enlarging windows
      7. Unpacking widgets
    2. Using the grid command
      1. Grid-based model
      2. Gridding options
      3. Resizing windows
      4. Mixing grid and pack
    3. Using the place command
      1. Coordinate-based model
      2. Custom geometry managers
  3. Handling Events
    1. The event loop
      1. Keyboard focus
      2. Forcing updates
      3. Handling long-running bindings
      4. Execution scope
      5. Quoting and the event loop
    2. Simple examples using bind
      1. Selecting an item from a listbox
      2. Automatic button help
      3. Class bindings
    3. Syntax of the bind command
      1. The event specification
      2. Percent substitutions
    4. More complex events
      1. Click, drag, drop
      2. Customizing widget behavior
    5. Binding tags
      1. Default binding tags
      2. Using break to interrupt event processing
      3. Inventing binding tags for groups of bindings
      4. Binding to a top-level window
    6. Debugging bindings
      1. Displaying bindings
      2. Monitoring events
    7. Animation
      1. Animating items on a canvas
      2. Debugging after events
      3. Library procedures for animation
  4. Using the Canvas Widget
    1. Understanding the canvas widget
      1. Scrolling
      2. Display list model
      3. Using tags
      4. Canvas bindings
    2. Scrollable form
    3. Progress page
    4. HSB color editor
    5. Tabbed notebook
    6. Calendar
      1. Handling size changes
      2. Sensors and callbacks
      3. Monitoring variables
    7. Simple drawing package
      1. Drawing items
      2. Selecting items
      3. Moving and deleting items
      4. Configuring items
      5. Resizing items
      6. Entering text
      7. Printing a drawing
      8. Saving a drawing
      9. Loading a drawing
  5. Using the Text Widget
    1. Understanding the text widget
      1. Indexing model
      2. Scrolling
      3. Using tags
      4. Text bindings
      5. Using marks
      6. Wrap modes
      7. Tab stops
    2. Simple text editor
    3. Read-only text display
    4. Appointment editor
      1. Using tags to apply styles
      2. Embedded windows
      3. Changing text bindings
      4. Retrieving appointments
    5. Hierarchical browser
      1. Hierarchical data
      2. Creating the hierarchical browser
      3. Using tags and marks
  6. Top-level Windows
    1. Toplevel widgets
    2. Setting the widgget class
    3. Communicating with the window managher
      1. Window placement
      2. Window size
    4. Simple dialogs
    5. Modal dialogs
    6. Controlling access to dialogs
      1. Create/destroy strategy
      2. Help from the window manager
      3. Show/hide strategy
    7. Unmanaged windows
      1. Introductory placard
      2. Balloon help
  7. Interacting with Other Programs
    1. Executing other programs
      1. Executing pipelines
      2. Building commands and handling errors
    2. Collecting output from long-running programs
    3. Driving other programs without temporary files
    4. Working around buffering problems
      1. Seeing the problem
      2. Fixing the problem
    5. Bidirectional pipes
      1. Buffering problems
      2. Writing and reading
      3. Graphical interface
    6. Client/server architectures
      1. Advantages
      2. Disadvantages
      3. A simple server
      4. A simple client
      5. Smarter parsing
      6. Safer parsing
      7. Asynchronous communication
      8. Handling multiline requests
    7. Network programming with sockets
      1. Overview
      2. A networked server
      3. A networked client
    8. A case study — the Electric Secretary
      1. Downloading appointments from the server
      2. Sending an appointment to the server
      3. Handling schedule conflicts
      4. Preferences
      5. Persistent storage
      6. Conclusions
  8. Delivering Tcl/Tk Applications
    1. Adding polish to your application
      1. Handling widget resources
      2. Handling unexpected errors
      3. Animated placard
    2. Creating Tcl/Tk libraries
      1. Designing library components
      2. Synthesizing data structures
      3. Adding callbacks to components
      4. Autoloading
      5. Packages
    3. Desktop applications
      1. Creating a distribution
      2. Making scripts into executable programs
      3. Making a self-installing programs
    4. Web-based applications
      1. Simple example
      2. A few important caveats
      3. Security policies
  9. Developing Cross-platform Applications
    1. User interface issues
      1. Menu bars
      2. Command dialogs
      3. Virtual events
      4. Fonts
      5. Option database
    2. File system issues
      1. File names
      2. File manipulation
      3. End-of-line translations
    3. Program invocation issues
      1. Communicating with other programs
      2. Environmental variables
    4. When all else fails
  1. Getting Started with Tcl/Tk
    1. Installing on Windows 85/NT
    2. Installing on UNIX
    3. Installing on Macintosh
  2. Annotated Bibliography

Reviews

Effective Tcl/Tk Programming

Reviewed by Roland Buresund

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

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

This is an excellent book if you're going to program in Tcl/Tk. Recommended.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required