10
[ Team LiB ] Table of Contents Index Examples Practical Programming in Tcl and Tk, Fourth Edition By Brent B. Welch , Ken Jones , Jeffrey Hobbs Publisher : Prentice Hall PTR Pub Date: June 10, 2003 ISBN: 0-13-038560-3 Pages: 960 Practical Programming in Tcl/Tk is described as the "bible" for Tcl programmers. It is a guide to the Tcl/Tk programming language and GUI toolkit. This revision includes substantial updates to cover the new version 8.4-giving both an overview of the features, as well as details about every command in the language. The third edition, written on version 8.2, sold over 30,000 copies. Version 8.4 of Tcl - Tool Command Language-provides substantial updates to one of the most popular UNIX scripting languages. The latest release, includes the addition of a virtual filesystem (VFS), many additional programming widgets (spinbox, panedwindow, labelframe),and improved performance of about 20% over 8.3. The book provides a guide to the best ways to use the tooklit. It not only gives accurate details, but includes extensive examples that demonstrate the best way to use the toolkit. The authors are experts that have both developed the technology and used it to solve problems, so they have many valuable insights to relate to the readers. [ Team LiB ]

Practical Programming in Tcl and Tk 4th Edition - baixardoc

Embed Size (px)

Citation preview

[ Team LiB ]

• Table of Contents

• I ndex

• Exam ples

Pract ical Program m ing in Tcl and Tk, Fourth Edit ion

By Brent B. Welch , Ken Jones, Jeffrey Hobbs

Publisher : Prent ice Hall PTR

Pub Date: June 10, 2003

I SBN: 0-13-038560-3

Pages: 960

Pract ical Program m ing in Tcl/ Tk is described as the "bible" for Tcl program m ers. I t is a guide to

the Tcl/ Tk program m ing language and GUI toolkit . This revision includes substant ial updates to

cover the new version 8.4-giving both an overview of the features, as well as details about

every com m and in the language. The third edit ion, writ ten on version 8.2, sold over 30,000

copies. Version 8.4 of Tcl - Tool Com m and Language-provides substant ial updates to one of the

m ost popular UNI X script ing languages. The latest release, includes the addit ion of a vir tual

filesystem (VFS) , m any addit ional program m ing widgets (spinbox, panedwindow,

labelfram e) ,and im proved perform ance of about 20% over 8.3. The book provides a guide to

the best ways to use the tooklit . I t not only gives accurate details, but includes extensive

exam ples that dem onst rate the best way to use the toolkit . The authors are experts that have

both developed the technology and used it to solve problem s, so they have m any valuable

insights to relate to the readers.

[ Team LiB ]

[ Team LiB ]

• Table of Contents

• I ndex

• Exam ples

Pract ical Program m ing in Tcl and Tk, Fourth Edit ion

By Brent B. Welch , Ken Jones, Jeffrey Hobbs

Publisher : Prent ice Hall PTR

Pub Date: June 10, 2003

I SBN: 0-13-038560-3

Pages: 960

Copyright

List of Exam ples

List of Tables

Preface

Why Tcl?

Tcl and Tk Versions

Extending Tcl and Tk

Tcl on the World Wide Web

Ftp Archives

Newsgroups

Who Should Read This Book

How to Read This Book

On- line Exam ples

Typographic Convent ions

Hot Tips

Book Organizat ion

What 's New in the Fourth Edit ion

Other Tcl Books

First Edit ion Thanks

Second Edit ion Thanks

Third Edit ion Thanks

Fourth Edit ion Thanks

Contact the Author

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

Part I . Tcl Basics

Chapter 1. Tcl Fundam entals

Tcl Com m ands

Hello, World!

Var iables

Com m and Subst itut ion

Math Expressions

Backslash Subst itut ion

Grouping with Braces and Double Quotes

Procedures

A Factorial Exam ple

More about Variables

More about Math Expressions

Com m ents

Subst itut ion and Grouping Sum m ary

Fine Points

Reference

Chapter 2. Get t ing Started

The source Com m and

UNI X Tcl Scripts

Windows Start Menu

Macintosh OS 8/ 9 and ResEdit

The console Com m and

Com m and-Line Argum ents

Predefined Variables

Chapter 3. The Guestbook CGI Applicat ion

A Quick I nt roduct ion to HTML

CGI for Dynam ic Pages

The guestbook.cgi Script

Defining Form s and Processing Form Data

Handling Errors in CGI Scripts

Next Steps

Chapter 4. St r ing Processing in Tcl

The string Com m and

The append Com m and

The format Com m and

The scan Com m and

The binary Com m and

Related Chapters

Chapter 5. Tcl Lists

Tcl Lists

Const ruct ing Lists

Get t ing List Elem ents: llength, lindex, and lrange

Modifying Lists: linsert and lreplace

Searching Lists: lsearch

Sort ing Lists: lsort

The split Com m and

The join Com m and

Related Chapters

Chapter 6. Cont rol St ructure Com m ands

If Then Else

Switch

While

Foreach

For

Break and Continue

Catch

Error

Return

Chapter 7. Procedures and Scope

The proc Com m and

Changing Com m and Nam es with rename

Scope

The global Com m and

Call by Nam e Using upvar

Variable Aliases with upvar

Chapter 8. Tcl Arrays

Array Syntax

The array Com m and

Building Data St ructures with Arrays

Chapter 9. Working with Files and Program s

Running Program s with exec

The file Com m and

Cross-Plat form File Nam ing

Manipulat ing Files and Director ies

File At t r ibutes

I nput / Output Com m and Sum m ary

Opening Files for I / O

Reading and Writ ing

The Current Directory - cd and pwd

Matching File Nam es with glob

The exit and pid Com m ands

Environm ent Variables

The registry Com m and

Part I I . Advanced Tcl

Chapter 10. Quot ing I ssues and Eval

Const ruct ing Code with the list Com m and

Exploit ing the concat inside eval

The uplevel Com m and

The subst Com m and

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

Chapter 11. Regular Expressions

When to Use Regular Expressions

Regular Expression Syntax

Advanced Regular Expressions

Syntax Sum m ary

The regexp Com m and

The regsub Com m and

Transform ing Data to Program with regsub

Other Com m ands That Use Regular Expressions

Chapter 12. Script Librar ies and Packages

Locat ing Packages: The auto_path Variable

Using Packages

Sum m ary of Package Loading

The package Com m and

Libraries Based on the tclIndex File

The unknown Com m and

I nteract ive Conveniences

Tcl Shell Library Environm ent

Coding Style

Chapter 13. Reflect ion and Debugging

The clock Com m and

The info Com m and

Cross-Plat form Support

Tracing Variables and Com m ands

I nteract ive Com m and History

Debugging

Tcl Dev Kit

Other Tools

Perform ance Tuning

Chapter 14. Nam espaces

Using Nam espaces

Nam espace Variables

Com m and Lookup

Nested Nam espaces

I m port ing and Export ing Procedures

Callbacks and Nam espaces

I nt rospect ion

The namespace Com m and

Convert ing Exist ing Packages to use Nam espaces

[incr Tcl] Object System

xotcl Object System

Notes

Chapter 15. I nternat ionalizat ion

Character Sets and Encodings

Message Catalogs

Chapter 16. Event -Driven Program m ing

The Tcl Event Loop

The after Com m and

The fileevent Com m and

The vwait Com m and

The fconfigure Com m and

Chapter 17. Socket Program m ing

Networking Extensions for Tcl

Client Sockets

Server Sockets

The Echo Service

Fetching a URL with HTTP

The http Package

Basic Authent icat ion

Chapter 18. TclHt tpd Web Server

I ntegrat ing TclHt tpd with Your Applicat ion

Dom ain Handlers

Applicat ion Direct URLs

Docum ent Types

HTML + Tcl Tem plates

Form Handlers

Program m ing Reference

Standard Applicat ion Direct URLs

The TclHt tpd Dist r ibut ion

Server Configurat ion

Chapter 19. Mult iple I nterpreters and Safe-Tcl

The interp Com m and

Creat ing I nterpreters

Safe I nterpreters

Com m and Aliases

Hidden Com m ands

Subst itut ions

I / O from Safe I nterpreters

The Safe Base

Security Policies

Chapter 20. Safe-Tk and the Browser Plugin

Tk in Child I nterpreters

The Browser Plugin

Security Policies and Browser Plugin

Configuring Security Policies

Chapter 21. Mult i-Threaded Tcl Scripts

What are Threads?

Thread Support in Tcl

Get t ing Started with the Thread Extension

Sending Messages to Threads

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

Preserving and Releasing Threads

Error Handling

Shared Resources

Managing I / O Channels

Shared Variables

Mutexes and Condit ion Variables

Thread Pools

The Thread Package Com m ands

Chapter 22. Tclkit and Starkits

Get t ing Started with Tclkit

Virtual File System s

Using sdx to Bundle Applicat ions

Explor ing the Virtual File System in a Starkit

Creat ing tclhttpd.kit

Creat ing a Shared Starkit

Metakit

More I deas

Part I I I . Tk Basics

Chapter 23. Tk Fundam entals

Hello, World! in Tk

Nam ing Tk Widgets

Configuring Tk Widgets

Tk Widget At t r ibutes and the Resource Database

Sum m ary of the Tk Com m ands

Other Widget Sets

Chapter 24. Tk by Exam ple

ExecLog

The Exam ple Browser

A Tcl Shell

Chapter 25. The Pack Geom etry Manager

Packing toward a Side

Horizontal and Vert ical Stacking

The Cavity Model

Packing Space and Display Space

Resizing and -expand

Anchor ing

Packing Order

Choosing the Parent for Packing

Unpacking a Widget

Packer Sum m ary

Window Stacking Order

Chapter 26. The Grid Geom etry Manager

A Basic Grid

Spanning Rows and Colum ns

Row and Colum n Const raints

The grid Com m and

Chapter 27. The Place Geom etry Manager

place Basics

The Pane Manager

The place Com m and

Chapter 28. The Panedwindow Widget

Using the Panedwindow

Program m ing Panedwindow Widgets

Panedwindow At t r ibutes

Chapter 29. Binding Com m ands to Events

The bind Com m and

The bindtags Com m and

Event Syntax

Modif iers

Event Sequences

Virtual Events

Generat ing Events

Event Sum m ary

Part I V. Tk Widgets

Chapter 30. But tons and Menus

But ton Com m ands and Scope I ssues

But tons Associated with Tcl Variables

But ton At t r ibutes

But ton Operat ions

Menus and Menubut tons

Menu Bindings and Events

Manipulat ing Menus and Menu Ent r ies

Menu At t r ibutes

A Menu by Nam e Package

Chapter 31. The Resource Database

An I nt roduct ion to Resources

Loading Opt ion Database Files

Adding I ndividual Database Ent r ies

Accessing the Database

User-Defined But tons

User-Defined Menus

Chapter 32. Sim ple Tk Widgets

Fram es, Labelfram es, and Toplevel Windows

The Label Widget

The Message Widget

The Scale Widget

The bell Com m and

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

Chapter 33. Scrollbars

Using Scrollbars

The Scrollbar Protocol

The Scrollbar Widget

Chapter 34. The Ent ry and Spinbox Widgets

Using Ent ry Widgets

Using Spinbox Widgets

Entry and Spinbox Bindings

Entry and Spinbox At t r ibutes

Program m ing Ent ry and Spinbox Widgets

Chapter 35. The Listbox Widget

Using Listboxes

The Listbox Widget

Listbox Bindings and Events

Listbox At t r ibutes

Chapter 36. The Text Widget

Text I ndices

Text Marks

Text Tags

The Select ion

Tag Bindings

Searching Text

Em bedded Widgets

Em bedded I m ages

Looking inside the Text Widget

The Undo Mechanism

Text Bindings and Events

Text Operat ions

Text At t r ibutes

Chapter 37. The Canvas Widget

Canvas Coordinates

Hello, World!

The Min Max Scale Exam ple

Canvas Objects

Canvas Operat ions

Generat ing Postscr ipt

Canvas At t r ibutes

Hints

Part V. Tk Details

Chapter 38. Select ions and the Clipboard>

The Select ion Model

The selection Com m and

The clipboard Com m and

Select ion Handlers

Chapter 39. Focus, Grabs, and Dialogs

Standard Dialogs

Custom Dialogs

Anim at ion with the update Com m and

Chapter 40. Tk Widget At t r ibutes

Configuring At t r ibutes

Size

Borders and Relief

The Focus Highlight

Padding and Anchors

Chapter 41. Color, I m ages, and Cursors

Colors

Colorm aps and Visuals

Bitm aps and I m ages

The Text I nsert Cursor

The Mouse Cursor

Chapter 42. Fonts and Text At t r ibutes

Nam ing a Font

X Font Nam es

Font Met r ics

The font Com m and

Text At t r ibutes

Gridding, Resizing, and Geom etry

A Font Select ion Applicat ion

Chapter 43. Send

The send Com m and

The Sender Script

Com m unicat ing Processes

Rem ote eval through Sockets

Chapter 44. Window Managers and Window I nform at ion

The wm Com m and

The winfo Com m and

The tk Com m and

Chapter 45. Managing User Preferences

App-Defaults Files

Defining Preferences

The Preferences User I nterface

Managing the Preferences File

Tracing Changes to Preference Variables

I m proving the Package

Chapter 46. A User I nterface to Bindings

A Pair of Listboxes Working Together

The Edit ing I nterface

Saving and Loading Bindings

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE

UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE