[Top] [Prev] [Next] [Bottom]
List of Examples
List of Tables
Preface
I Tcl Basics
1. Tcl Fundamentals
- Tcl Commands
- Hello, World!
- Variables
- Command Substitution
- Math Expressions
- Backslash Substitution
- Grouping with Braces and Double Quotes
- Square Brackets Do Not Group
- Grouping before Substitution
- Procedures
- A Factorial Example
- More about Variables
- Funny Variable Names
- The unset Command
- Using info to Find Out about Variables
- More about Math Expressions
- Comments
- Substitution and Grouping Summary
- Fine Points
- Reference
- Backslash Sequences
- Arithmetic Operators
- Built-in Math Functions
- Core Tcl Commands
2. Getting Started
- The source Command
- UNIX Tcl Scripts
- Windows 95 Start Menu
- The Macintosh and ResEdit
- The console Command
- Command-Line Arguments
- Command-Line Options to Wish
- Predefined Variables
3. The Guestbook CGI Application
- A Quick Introduction to HTML
- CGI for Dynamic Pages
- The guestbook.cgi Script
- Beginning the HTML Page
- Simple Tags and Hypertext Links
- Using a Tcl Array for the Database
- Sample Output
- Defining Forms and Processing Form Data
- The newguest.html Form
- The newguest.cgi Script
- Next Steps
4. String Processing in Tcl
- The string Command
- Strings and Expressions
- The append Command
- The format Command
- The scan Command
- String Matching
- The binary Command
- Format Templates
- Examples
- Related Chapters
5. Tcl Lists
- Tcl Lists
- Constructing Lists
- The list command
- The lappend Command
- The concat Command
- Getting List Elements: llength, lindex, and lrange
- Modifying Lists: linsert and lreplace
- Searching Lists: lsearch
- Sorting Lists: lsort
- The split Command
- The join Command
- Related Chapters
6. Control Structure Commands
- If Then Else
- Switch
- Comments in switch Commands
- While
- Foreach
- Multiple Loop Variables
- Multiple Value Lists
- For
- Break and Continue
- Catch
- Catching More Than Errors
- Error
- Return
7. Procedures and Scope
- The proc Command
- Changing Command Names with rename
- Scope
- The global Command
- Call by Name Using upvar
- Variable Aliases with upvar
- Associating State with Data
- Commands That Take Variable Names
8. Tcl Arrays
- Array Syntax
- Complex Indices
- Array Variables
- The array Command
- Converting Arrays to Lists
- Passing Arrays by Name
- Building Data Structures with Arrays
- Simple Records
- A Stack
- A List of Arrays
9. Working with Files and Programs
- Running Programs with exec
- The auto_noexec Variable
- Limitations of exec on Windows
- Limitations of exec on Macintosh
- The file Command
- Cross-Platform File Naming
- Building up Pathnames: file join
- Chopping Pathnames: split, dirname, tail
- Manipulating Files and Directories
- Copying Files
- Creating Directories
- Deleting Files
- Renaming Files and Directories
- File Attributes
- Input/Output Command Summary
- Opening Files for I/O
- Opening a Process Pipeline
- Reading and Writing
- The puts and gets Commands
- The read Command
- Platform-Specific End of Line Characters
- Random Access I/O
- Closing I/O channels
- The Current Directory - cd and pwd
- Matching File Names with glob
- Expanding Tilde in File Names
- The exit and pid Commands
- Environment Variables
II Advanced Tcl
10. Eval
- Construct Commands with list
- Exploiting the concat inside eval
- Double Quotes and eval
- More Examples
- The uplevel Command
- Commands That Concatenate Their Arguments
- The subst Command
- String Processing with subst
11. Regular Expressions
- Regular Expression Syntax
- A Pattern to Match URLs
- The regexp Command
- Useful Regular Expressions
- The regsub Command
- Transforming Data to Tcl with regsub
- URL Decoding
- CGI Argument Parsing
- Decoding HTML Entities
- A Simple HTML Parser
- Stripping HTML Comments
- Other Commands That Use Regular Expressions
12. Script Libraries and Packages
- Locating Packages: The auto_path Variable
- Using Packages
- Loading Packages Automatically
- Packages Implemented in C Code
- The package Command
- Libraries Based on the tclIndex File
- The unknown Command
- How Auto Loading Works
- Disabling the Library Facility: auto_noload
- Interactive Conveniences
- Auto Execute
- History
- Abbreviations
- Tcl Shell Library Environment
- Coding Style
- A Module Prefix for Procedure Names
- A Global Array for State Variables
13. Reflection and Debugging
- The clock Command
- The info Command
- Variables
- Procedures
- The Call Stack
- Command Evaluation
- Scripts and the Library
- Version Numbers
- Execution Environment
- Cross-Platform Support
- Tracing Variable Values
- Interactive Command History
- History Syntax
- A Comparison to C Shell History Syntax
- Debugging
- Don Libes' Debugger
- Breakpoints by Pattern Matching
- Deleting Break Points
- Debugging Tk Scripts
- The tkinspect Program
- The tdebug Program
- The bgerror Command
- The tkerror Command
- Performance Tuning
- Time stamps in a Log
- Tcl 8.0
14. Namespaces
- Using Namespaces
- Namespace Variables
- Qualified Names
- Command Lookup
- Nested Namespaces
- Importing Procedures
- Other Namespaces
- Callbacks and Namespaces
- Introspection
- The namespace Command
- Wrapping Existing Packages
- [incr Tcl] Object System
- Notes
- Auto Loading
- Namespaces and uplevel
- Naming Quirks
- Miscellaneous
15. Event-Driven Programming
- The Tcl Event Loop
- The after Command
- The fileevent Command
- The vwait Command
- The fconfigure Command
- Non-Blocking I/O
- The fblocked Command
- Buffering
- End of Line Translations
- End of File Character
- Serial Devices
- Configuring Read-Write Channels
16. Socket Programming
- Client Sockets
- Client Socket Options
- Server Sockets
- Server Socket Options
- The Echo Service
- Fetching a URL with HTTP
- Proxy Servers
- The HEAD Request
- The GET and POST Requests
- The unsupported0 Command
- The fcopy Command
- The http Package
- http_config
- http_get
- http_formatQuery
- http_reset
17. Multiple Interpreters and
Safe-Tcl
- The interp Command
- Creating Interpreters
- The Interpreter Hierarchy
- The Interpreter Name as a Command
- Use list with interp eval
- Safe Interpreters
- Command Aliases
- Alias Introspection
- Hidden Commands
- Substitutions
- I/O from Safe Interpreters
- The Safe Base
- Security Policies
- Limited Socket Access
- Limited Temporary Files
- Safe after Command
III Tk Basics
18. Tk Fundamentals
- Hello, World! in Tk
- Naming Tk Widgets
- Configuring Tk Widgets
- Tk Widget Attributes and the Resource Database
- The Tk Manual Pages
- Summary of the Tk Commands
19. Tk by Example
- ExecLog
- Window Title
- A Frame for Buttons
- Command Buttons
- A Label and an Entry
- Key Bindings and Focus
- A Resizable Text and Scrollbar
- The Run Procedure
- The Log Procedure
- The Stop Procedure
- Cross-Platform Issues
- The Example Browser
- More about Resizing Windows
- Managing Global State
- Searching through Files
- Cascaded Menus
- A Read-Only Text Widget
- A Tcl Shell
- Text Marks, Tags, and Bindings
- Multiple Interpreters
- Native Look and Feel
20. The Pack Geometry Manager
- Packing toward a Side
- Shrinking Frames and pack propagate
- Horizontal and Vertical Stacking
- The Cavity Model
- Packing Space and Display Space
- The -fill Option
- Internal Padding with -ipadx and -ipady
- External Padding with -padx and -pady
- Resizing and -expand
- Anchoring
- Packing Order
- Introspection
- Pack the Scrollbar First
- Choosing the Parent for Packing
- Unpacking a Widget
- Packer Summary
- The pack Command
- Window Stacking Order
21. The Grid Geometry Manager
- A Basic Grid
- The -sticky Setting
- External Padding with -padx and -pady
- Internal Padding with -ipadx and -ipady
- Multiple Widgets in a Cell
- Spanning Rows and Columns
- Row and Column Constraints
- Row and Column Padding
- Minimum Size
- Managing Resize Behavior
- The grid Command
22. The Place Geometry Manager
- place Basics
- The Pane Manager
- Parsing Arguments and Maintaining State
- Sticky Geometry Settings
- Event Bindings
- Managing the Layout
- The place Command
23. Binding Commands to Events
- The bind Command
- The bindtags Command
- Focus and Key Events
- Using break and continue in Bindings
- Defining New Binding Tags
- Binding Precedence in Tk 3.6
- Event Syntax
- Keyboard Events
- Detecting Modifiers in Tk 3.6
- Mouse Events
- Other Events
- Bindings on Top-level Windows
- Modifiers
- Modifiers in Tk 3.6
- Event Sequences
- Virtual Events
- Event Keywords
IV Tk Widgets
24. Buttons and Menus
- Button Commands and Scope Issues
- Buttons Associated with Tcl Variables
- Button Attributes
- Button Operations
- Menus and Menubuttons
- A Menu Bar
- System Menus
- Pop-Up Menus
- Option Menus
- Multicolumn Palette Menus
- Keyboard Traversal
- Manipulating Menus and Menu Entries
- Menu Attributes
- A Menu by Name Package
- Menu Accelerators
25. The Resource Database
- An Introduction to Resources
- Resource Patterns
- Loading Option Database Files
- Adding Individual Database Entries
- Accessing the Database
- User-Defined Buttons
- User-Defined Menus
- Application and User Resources
- Expanding Variables
26. Simple Tk Widgets
- Frames and Toplevel Windows
- Attributes for Frames and Toplevels
- Embedding Other Applications
- Toplevel Window Styles
- The Label Widget
- Label Width and Wrap Length
- Label Attributes
- The Message Widget
- Message Attributes
- Arranging Labels and Messages
- The Scale Widget
- Scale Bindings
- Scale Attributes
- Programming Scales
- The bell Command
27. Scrollbars
- Using Scrollbars
- The Scrollbar Protocol
- The Scrollbar set Operation
- The xview and yview Operations
- The Tk 3.6 Protocol
- The Scrollbar Widget
- Scrollbar Bindings
- Scrollbar Attributes
- Programming Scrollbars
28. The Entry Widget
- Using Entry Widgets
- Tips for Using Entry Widgets
- The Entry Widget
- Entry Attributes
- Programming Entry Widgets
29. The Listbox Widget
- Using Listboxes
- Programming Listboxes
- Listbox Bindings
- Browse Select Mode
- Single Select Mode
- Extended Select Mode
- Multiple Select Mode
- Scroll Bindings
- Listbox Attributes
- Geometry Gridding
30. The Text Widget
- Text Indices
- Inserting and Deleting Text
- Index Arithmetic
- Comparing Indices
- Text Marks
- Mark Gravity
- Text Tags
- Tag Attributes
- Mixing Attributes from Different Tags
- Line Spacing and Justification
- Tab Stops
- The Selection
- Tag Bindings
- Searching Text
- Embedded Widgets
- Embedded Images
- Looking inside the Text Widget
- Looking at Tags
- Looking at Marks
- Dumping the Contents
- Text Bindings
- Text Operations
- Text Attributes
31. The Canvas Widget
- Canvas Coordinates
- Hello, World!
- Canvas Tags
- The Min Max Scale Example
- Canvas Objects
- Arc Items
- Bitmap Items
- Image Items
- Line Items
- Oval Items
- Polygon Items
- Rectangle Items
- Text Items
- Window Items
- Canvas Operations
- Generating Postscript
- Canvas Attributes
- Hints
- Screen Coordinates vs. Canvas Coordinates
- Large Coordinate Spaces
- Scaling and Rotation
- Resources
- Objects with Many Points
- Selecting Canvas Items
V Tk Details
32. Selections and the Clipboard
- The Selection Model
- The selection Command
- The clipboard Command
- Selection Handlers
- A Canvas Selection Handler
33. Focus, Grabs, and Dialogs
- Standard Dialogs
- Message Box
- File Dialogs
- Color Dialog
- Custom Dialogs
- Input Focus
- The focus Command
- Keyboard Focus Traversal
- Grabbing the Focus
- The tkwait Command
- Destroying Widgets
- The focus, grab, tkwait sequence
- Prompter Dialog
- Keyboard Shortcuts and Focus
- Animation with the update Command
34. Tk Widget Attributes
- Configuring Attributes
- Size
- Borders and Relief
- The Focus Highlight
- Padding and Anchors
- Putting It All Together
35. Color, Images, and Cursors
- Colors
- Color Palettes
- Color Values
- Colormaps and Visuals
- Bitmaps and Images
- The image Command
- Bitmap Images
- The bitmap Attribute
- Photo Images
- The Text Insert Cursor
- The Mouse Cursor
36. Fonts and Text Attributes
- Naming a Font
- Named Fonts
- System Fonts
- X Font Names
- Font Failures before Tk 8.0
- Font Metrics
- The font Command
- Text Attributes
- Layout
- Selection Attributes
- Gridding, Resizing, and Geometry
- A Font Selection Application
37. Send
- The send Command
- Send and X Authority
- The Sender Script
- Communicating Processes
- Remote eval through Sockets
38. Window Managers and Window Information
- The wm Command
- Size, Placement, and Decoration
- Icons
- Session State
- Miscellaneous
- The winfo Command
- Sending Commands between Applications
- Family Relationships
- Size
- Location
- Virtual Root Window
- Atoms and IDs
- Colormaps and Visuals
- The tk Command
39. Managing User Preferences
- App-Defaults Files
- Defining Preferences
- The Preferences User Interface
- Managing the Preferences File
- Tracing Changes to Preference Variables
- Improving the Package
40. A User Interface to Bindings
- A Pair of Listboxes Working Together
- The Editing Interface
- Saving and Loading Bindings
VI C Programming
41. C Programming and Tcl
- Using the Tcl C Library
- Application Structure
- Creating a Loadable Package
- The load Command
- Using Tcl_PkgProvide
- A C Command Procedure
- The String Command Interface
- Managing String Result
- The Object Command Interface
- Managing Object Reference Counts
- Tcl_Main and Tcl_AppInit
- Tk_Main
- The Event Loop
- Invoking Scripts from C
- Bypassing Tcl_Eval
- Expect's Tcl Debugger
- The Dbg C Interface
- Handling SIGINT
- Putting a Tcl Program Together
- A Simple UNIX Example
- Autoconf
- Windows
- Macintosh
42. C Library Overview
- An Overview of the Tcl C Library
- Application Initialization
- Creating and Deleting Interpreters
- Creating and Deleting Commands
- Dynamic Loading and Packages
- Managing the Result String
- Memory Allocation
- Lists and Command Parsing
- Command Pipelines
- Tracing the Actions of the Tcl Interpreter
- Evaluating Tcl Commands
- Reporting Script Errors
- Manipulating Tcl Variables
- Evaluating Expressions
- Converting Numbers
- Tcl Objects
- Primitive Object Types
- String Keys for Data Structures
- Option Processing
- Hash Tables
- Dynamic Strings
- Regular Expressions and String Matching
- Event Loop Interface
- Handling Window Events
- File Handlers
- Timer Events
- Idle Callbacks
- Sleeping
- Event Loop Implementation
- Input/Output
- I/O Channel Drivers
- Manipulating File Names
- Working with Signals
- Exit Handlers
- An Overview of the Tk C Library
- Parsing Command-Line Arguments
- The Standard Application Setup
- Creating Windows
- Application Name for Send
- Configuring Windows
- Window Coordinates
- Window Stacking Order
- Window Information
- Configuring Widget Attributes
- Safe Handling of the Widget Data Structure
- The Selection and Clipboard
- Event Bindings
- Handling Graphic Protocol Errors
- Using the Resource Database
- Managing Bitmaps
- Creating New Image Types
- Using an Image in a Widget
- Photo Image Types
- Canvas Object Support
- Geometry Management
- String Identifiers (UIDS)
- Colors, Colormaps, and Visuals
- 3D Borders
- Mouse Cursors
- Fonts and Text Display
- Graphics Contexts
- Allocate a Pixmap
- Screen Measurements
- Relief Style
- Text Anchor Positions
- Line Cap Styles
- Line Join Styles
- Text Justification Styles
- Atoms
- X Resource ID Management
43. Writing a Tk Widget in C
- The Widget Data Structure
- The Widget Class Command
- The Widget Instance Command
- Configuring and Reconfiguring Attributes
- Specifying Widget Attributes
- Displaying the Clock
- The Window Event Procedure
- Final Cleanup
VII Changes
44. Tcl 7.4/Tk 4.0
- wish
- Obsolete Features
- The cget Operation
- Input Focus Highlight
- Bindings
- Scrollbar Interface
- pack info
- Focus
- The send Command
- Internal Button Padding
- Radiobutton Value
- Entry Widget
- Menus
- Listboxes
- No geometry Attribute
- Text Widget
- Color Attributes
- Color Allocation and tk colormodel
- Canvas scrollincrement
- The Selection
- The bell Command
45. Tcl 7.5/Tk 4.1
- Cross-Platform Scripts
- File Name Manipulation
- Newline Translations
- The tcl_platform Variable
- The console Command
- The clock Command
- The load Command
- The package Command
- Multiple foreach loop variables
- Event Loop Moves from Tk to Tcl
- Network Sockets
- info hostname
- The fconfigure Command
- Multiple Interpreters and Safe-Tcl
- The grid Geometry Manager
- The Text Widget
- The Entry Widget
46. Tcl 7.6/Tk 4.2
- More file Operations
- Virtual Events
- Standard Dialogs
- New grid Geometry Manager
- Macintosh unsupported1 Command
47. Tcl/Tk 8.0
- The Tcl Compiler
- Compile-Time Errors
- Binary String Support
- Namespaces
- Safe-Tcl
- New lsort
- No tcl_precision Variable
- Year 2000 Convention
- Http Package
- Serial Line I/O
- Platform-Independent Fonts
- The tk scale Command
- Application Embedding
- Native Menus and Menubars
- CDE Border Width
- Native Buttons and Scrollbars
- Images in Text Widgets
- No Errors from destroy
- grid rowconfigure
- Late Breaking News
48. Safe-Tk and
the Browser Plug-In
- Tk in Child Interpreters
- Embedding Tk Windows
- Safe-Tk Restrictions
- The Browser Plug-In
- Setting Up the Plug-In
- UNIX Configuration
- Windows Configuration
- Macintosh Configuration
- Security Policies and Browser Plug-in
- The Browser Package
- Configuring Security Policies
- Notes
[Top] [Prev] [Next] [Bottom]
welch@acm.org
Copyright © 1997, Brent Welch. All rights
reserved.
This will be published by Prentice Hall as the 2nd Edition of
Practical Programming in Tcl and Tk