1. Tcl Fundamentals
1-1 Backslash sequences
1-2 Arithmetic operators from highest to lowest precedence 1-3 Built-in math functions
1-4 Built-in Tcl commands 2. Getting Started
2-1 Wish command line options
2-2 Variables defined by tclsh and wish 3. The Guestbook CGI Application
3-1 HTML tags used in the examples 4. String Processing in Tcl
4-1 The string command
4-2 Matching characters used with string match
4-3 Character class names 4-4 Format conversions 4-5 Format flags
4-6 Binary conversion types 5. Tcl Lists
5-1 List-related commands
5-2 Options to the lsearch command 8. Tcl Arrays
8-1 The array command
9. Working with Files and Programs
9-1 Summary of the exec syntax for I/O redirection 9-2 The file command options
9-6 Summary of the open access arguments
9-7 Summary of POSIX flags for the access argument 9-8 glob command options
9-9 The registry command
9-10 The registry data types 11. Regular Expressions
11-1 Additional advanced regular expression syntax 11-2 Backslash escapes in regular expressions 11-3 Character classes
11-4 Embedded option characters used with the (?x) syntax 11-5 Options to the regexp command
11-6 Sample regular expressions 12. Script Libraries and Packages
12-1 Options to the pkg_mkIndex command 12-2 The package command
13. Reflection and Debugging 13-1 clock format keywords 13-2 The clock command 13-3 The info command 13-4 The history command 13-5 Special history syntax 14. Namespaces
14-1 The namespace command 15. Internationalization
15-1 The encoding command 15-2 The msgcat package 16. Event-Driven Programming
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
16-4 Serial line properties controlled by fconfigure
16-5 End of line translation modes 17. Socket Programming
17-1 Options to the http::geturl command 17-2 The http support procedures
17-3 Elements of the http::geturl state array 18. TclHttpd Web Server
18-1 Httpd support procedures 18-2 Url support procedures
18-3 Doc procedures for configuration
18-4 Doc procedures for generating responses
18-5 Doc procedures that support template processing 18-6 Elements of the page array
18-7 Elements of the env array 18-8 Status Application Direct URLs 18-9 Debug Application Direct URLs
18-10 Application Direct URLS that email form results 18-11 Basic TclHttpd parameters
19. Multiple Interpreters and Safe-Tcl 19-1 The interp command
19-2 Commands hidden from safe interpreters 19-3 The safe base master interface
19-4 The safe base slave aliases 20. Safe-Tk and the Browser Plugin
20-1 Tk commands omitted from safe interpreters 20-2 Aliases defined by the browser package 20-3 The browser::getURL callbacks
21-3 The commands of the tsv namespace 21-4 The commands of the tpool namespace 21-5 Thread pool configuration options
22. Tclkit and Starkits
22-1 Return values of the starkit::startup procedure 23. Tk Fundamentals
23-1 Tk widget-creation commands 23-2 Tk widget-manipulation commands 23-3 Tk support procedures
25. The Pack Geometry Manager 25-1 The pack command 25-2 Packing options 26. The Grid Geometry Manager
26-1 The grid command 26-2 Grid widget options 27. The Place Geometry Manager
27-1 The place command 27-2 Placement options 28. The Panedwindow Widget
28-1 Panedwindow operations 28-2 Panedwindow attributes
28-3 Panedwindow managed widget options 29. Binding Commands to Events
29-1 Event types 29-2 Event modifiers 29-3 The event command
29-4 A summary of the event keywords
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
30-3 Menu entry index keywords 30-4 Menu operations
30-5 Menu attribute resource names 30-6 Attributes for menu entries 32. Simple Tk Widgets
32-1 Attributes for frame, labelframe, and toplevel widgets 32-2 Label Attributes
32-3 Message Attributes 32-4 Bindings for scale widgets 32-5 Attributes for scale widgets 32-6 Operations on the scale widget 33. Scrollbars
33-1 Attributes for the scrollbar widget 33-2 Bindings for the scrollbar widget 33-3 Operations on the scrollbar widget 34. The Entry and Spinbox Widgets
34-1 Entry and spinbox validation substitutions 34-2 Entry and spinbox bindings
34-3 Entry and spinbox attribute resource names 34-4 Entry and spinbox indices
34-5 Entry and spinbox operations 35. The Listbox Widget
35-1 Listbox indices 35-2 Listbox operations
35-3 Listbox item configuration options
35-4 The values for the selectMode of a listbox 35-5 Bindings for browse selection mode
35-9 Listbox scroll bindings
35-10 Listbox attribute resource names 36. The Text Widget
36-1 Text indices
36-2 Index modifiers for text widgets 36-3 Attributes for text tags
36-4 Options to the search operation 36-5 Window and image alignment options 36-6 Options to the window create operation 36-7 Options to the image create operation 36-8 Bindings for the text widget
36-9 Operations for the text widget 36-10 Text attribute resource names 37. The Canvas Widget
37-1 Common canvas item attributes 37-2 Canvas dash pattern characters 37-3 Arc attributes
37-4 Bitmap attributes 37-5 Image attributes 37-6 Line attributes 37-7 Polygon attributes
37-8 Indices for canvas text items
37-9 Canvas operations that apply to text items 37-10 Text attributes
37-11 Window attributes
37-12 Operations on a canvas widget 37-13 Canvas postscript options
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
38-2 The clipboard command 39. Focus, Grabs, and Dialogs
39-1 Options to tk_messageBox
39-2 Options to the standard file and directory dialogs 39-3 Options to tk_chooseColor
39-4 The focus command 39-5 The grab command 39-6 he tkwait command 40. Tk Widget Attributes
40-1 Size attribute resource names
40-2 Border and relief attribute resource names 40-3 Highlight attribute resource names
40-4 Layout attribute resource names 41. Color, Images, and Cursors
41-1 Color attribute resource names 41-2 Windows system colors
41-3 Macintosh system colors 41-4 Visual classes for displays
41-5 Summary of the image command 41-6 Bitmap image options
41-7 Photo image attributes 41-8 Photo image operations
41-9 Copy options for photo images 41-10 Read options for photo images 41-11 Write options for photo images 41-12 Cursor attribute resource names 42. Fonts and Text Attributes
42-4 The font command
42-5 Selection attribute resource names 43. Send
43-1 Options to the send command 44. Window Managers and Window Information
44-1 Size, placement and decoration window manager operations 44-2 Window manager commands for icons
44-3 Session-related window manager operations 44-4 Miscellaneous window manager operations 44-5 send command information
44-6 Window hierarchy information 44-7 Window location information 44-8 Window size information
44-9 Virtual root window information 44-10 Atom and window ID information 44-11 Colormap and visual class information 44-12 The tk command operations
47. C Programming and Tcl
47-1 Defines to control the meaning of CONST in the Tcl APIs 48. Compiling Tcl and Extensions
48-1 The Tcl source directory structure 48-2 The installation directory structure 48-3 Standard configure flags
48-4 TEA standard Makefile targets 49. Writing a Tk Widget in C
49-1 Configuration flags and corresponding C types 51. Tcl 7.4/Tk 4.0
UNREGISTERED VERSION OF CHM TO PDF CONVERTER By THETA-SOFTWARE
55-2 The dde command options [ Team LiB ]
Preface
Tcl stands for Tool Command Language. Tcl is really two things: a scripting language, and an
interpreter for that language that is designed to be easy to embed into your application. Tcl and its associated graphical user-interface toolkit, Tk, were designed and crafted by Professor John Ousterhout of the University of California, Berkeley. You can find these packages on the Internet and use them freely in your application, even if it is commercial. The Tcl interpreter has been ported from UNIX to DOS, PalmOS, VMS, Windows, OS/2, NT, and Macintosh environments. The Tk toolkit has been ported from the X window system to Windows and Macintosh.
I first heard about Tcl in 1988 while I was Ousterhout's Ph.D. student at Berkeley. We were designing a network operating system, Sprite. While the students hacked on a new kernel, John wrote a new editor and terminal emulator. He used Tcl as the command language for both tools so that users could define menus and otherwise customize those programs. This was in the days of X10, and he had plans for an X toolkit based on Tcl that would help programs cooperate with each other by communicating with Tcl commands. To me, this cooperation among tools was the essence of Tcl.
This early vision imagined that applications would be large bodies of compiled code and a small amount of Tcl used for configuration and high-level commands. John's editor, mx, and the terminal emulator, tx, followed this model. While this model remains valid, it has also turned out to be possible to write entire applications in Tcl. This is because the Tcl/Tk shell, wish, provides access to other programs, the file system, network sockets, plus the ability to create a graphical user interface. For better or worse, it is now common to find applications that contain thousands of lines of Tcl script.
This book was written because, while I found it enjoyable and productive to use Tcl and Tk, there were times when I was frustrated. In addition, working at Xerox PARC, with many experts in languages and systems, I was compelled to understand both the strengths and weaknesses of Tcl and Tk. Although many of my colleagues adopted Tcl and Tk for their
projects, they were also just as quick to point out its flaws. In response, I have built up a set of programming techniques that exploit the power of Tcl and Tk while avoiding troublesome areas. This book is meant as a practical guide to help you get the most out of Tcl and Tk and avoid some of the frustrations I experienced.
It has been about 14 years since I was introduced to Tcl, and about eight years since the first edition of this book. During several of those years I worked under John Ousterhout, first at Sun Microsystems and then at Scriptics Corporation. There I remained mostly a Tcl programmer while others in our group have delved into the C implementation of Tcl itself. I've built
applications like HTML editors, email user interfaces, Web servers, and the customer database we ran our business on. This experience is reflected in this book. The bulk of the book is about Tcl scripting, and the aspects of C programming to create Tcl extensions is given a lighter treatment. I have been lucky to remain involved in the core Tcl development, and I hope I can pass along the insights I have gained by working with Tcl.