Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword or section
Like this

Table Of Contents

Tcl Fundamentals 1
Getting Started
Tcl Commands
Hello World
Example 1–1 The “Hello, World!” example
Command Substitution
Math Expressions
Backslash Substitution
Example 1–8 Quoting special characters with backslash
Double Quotes
Example 1–10 Grouping with double quotes allows substitutions
A While Loop Example
Example 1–12 A loop that multiplies the numbers from 1 to 10
Grouping And Command Substitution
Example 1–13 Embedded command and variable substitution
More About Variable Substitution
Substitution And Grouping Summary
Fine Points
Command Line Arguments
Backslash Sequences
Arithmetic Operators
Table 1–2 Arithmetic Operators from highest to lowest precedence
Built-in Math Functions
Core Tcl Commands
Strings and Pattern Matching 2
The string Command
Strings And Expresssions
The append Command
The format Command
The scan Command
String Matching
Regular Expressions
The regexp Command
Example 2–2 Regular expression to parse the DISPLAY environment variable
The regsub Command
Tcl Data Structures 3
More About Variables
The unset command
Using info to find out about variables
Example 3–2 Using info to determine if a variable exists
Tcl Lists
Constructing Lists: list, lappend, and concat
Example 3–6 Double quotes compared to the list command
Getting List Elements: llength, lindex, and lrange
Modifying Lists: linsert and lreplace
Searching Lists: lsearch
Sorting Lists: lsort
The split And join Commands
Example 3–12 What if the name of the array is in a variable
The array Command
Environment Variables
Tracing Variable Values
Control Flow Commands 4
If Then Else
Example 4–4 Using switch with substitutions in the patterns
Example 4–5 Using switch with all pattern body pairs grouped with quotes
Example 4–9 A while loop to read standard input
Break And Continue
Example 4–13 The results of error with no info argument
Procedures and Scope 5
The proc Command
Changing command names with rename
The global Command
Use Arrays for Global State
Call By Name Using upvar
Passing arrays by name
Example 5–8 Using an array to implement a stack
The uplevel Command
Eval And List
Eval And Concat
Double-quotes and eval
Commands That Concat Their Arguments
The subst Command
Working with UNIX 7
Running Unix Programs With exec
Table 7–1 Summary of the exec syntax for I/O redirection
Looking At The File System
Opening Files For I/O
Table 7–4 Summary of the open access arguments
Reading And Writing
The puts and gets commands
The read command
Random access I/O
Closing I/O streams
The Current Directory - cd And pwd
Matching File Names With glob
The exit And pid commands
The info Command
The call stack
Command evaluation
Scripts and the library
Version numbers
Interactive Command History
History syntax
A comparision to /bin/csh history syntax
Example 8–4 Implementing special history syntax
Don Libes’ debugger
Breakpoints by pattern matching
Deleting break points
The tkerror Command
The tkinspect Program
Performance Tuning
Script Libraries 9
The unknown Command
The tclIndex File
Using A Library: auto_path
Disabling the library facility: auto_noload
How Auto Loading Works
Interactive Conveniences
Auto Execute
Tcl Shell Library Environment
Coding Style
A module prefix for procedure names
A global array for state variables
Tk Fundamentals 10
Hello World In Tk
Naming Tk Widgets
About The Tk Man Pages
Summary Of The Tk Commands
Tk by Example 11
Window title
A frame for buttons, etc
Command buttons
A label and an entry
Key bindings and focus
A resizable text and scrollbar
The Run proc
The Log procedure
The Stop procedure
The Example Browser
Example 11–2 A browser for the code examples in the book
More about resizing windows
Managing global state
Cascaded menus
The Browse proc
A Tcl Shell
Naming issues
Text marks and bindings
The Pack Geometry Manager 12
Packing towards a side
Shrinking frames and pack propagate
Horizontal And Vertical Stacking
Example 12–4 Even more nesting of horizontal and vertical stacks
The Cavity Model
Packing Space and Display Space
Choosing The Parent For Packing
Unpacking a Widget
Packer Summary
The pack Command
The Place Geometry Manager
The place Command
Window Stacking Order
Binding Commands to X Events13
The bind Command
All, Class, And Widget Bindings
The bindtags command
break and continue in bindings
A note about bindings in earlier versions of Tk
Event Syntax
Table 13–1 Event types. Comma-separated types are equivalent
Key Events
Button Events
Other Events
Events in Tk 3.6 and earlier
Event Sequences
Event Keywords
Buttons and Menus 14
Button Commands and Scope Issues
Buttons Associated with Tcl Variables
Button Attributes
Button Operations
Menus and Menubuttons
Manipulating Menus and Menu Entries
A Menu by Name Package
Example 14–11 Keeping the accelerator display up-to-date
Popup Menus and Option Menus
Keyboard Traversal
Menu Attributes
Table 14–5 Resource names of attributes for menu widgets
Simple Tk Widgets 15
Frames and Top-Level Windows
Attributes for frames and toplevels
Table 15–1 Resource names of attributes for frame and toplevel widgets
The label Widget
Label attributes
Label width and wrapLength
Table 15–2 Resource names of attributes for label widgets
The message Widget
Example 15–2 The message widget formats long lines of text
Example 15–3 Controlling the text layout in a message widget
Message Attributes
Arranging Labels and Messages
The scale Widget
Scale attributes
Programming scales
The scrollbar Widget
Scrollbar attributes
Table 15–7 Default bindings for scrollbar widgets
Table 15–8 Resource names of attributes for scrollbar widgets
Programming scrollbars
The Tk 3.6 protocol
The bell Command
Entry and Listbox Widgets 16
The entry Widget
entry attributes
Table 16–2 Resource names for attributes of entry widgets
Programming entry widgets
The listbox Widget
Example 16–3 A listbox with scrollbars and better alignment
Programming listboxes
Listbox Bindings
Browse select mode
Single select mode
Table 16–9 Bindings for a listbox in single selectMode
Extended select mode
Multiple select mode
Scroll bindings
Table 16–11 Bindings for multiple selection mode
listbox attributes
Table 16–12 Scroll bindings common to all selection modes
Geometry gridding
Focus, Grabs, and Dialogs 17
Input Focus
The focus command
Focus follows mouse
Example 17–1 Setting focus-follows-mouse input focus model
Click to type
Hybrid models
Grabbing the Focus
The tkwait Command
Prompter dialog
Destroying widgets
Focusing on buttons
Animation with the update command
File Selection Dialog
Creating the dialog
Listing the directory
Accepting a name
Easy stuff
File name completion
The text Widget 18
Text widget taxonomy
Text Indices
Text Marks
Text Tags
Tag attributes
Mixing attributes from different tags
The Selection
Tag Bindings
Embedded Widgets
Text Bindings
Text Operations
Text Attributes
Table 18–7 Resource names of attributes for text widgets
The canvas Widget 19
Hello, World!
Example 19–1 The canvas Hello, World! example
The Double-Slider Example
Example 19–2 A double slider canvas example
Canvas Coordinates
Bitmap Items
Line Items
Example 19–8 A canvas stroke drawing example
Oval Items
Polygon Items
Rectangle Items
Text Items
Table 19–7 Attributes for rectangle canvas items
Example 19–12 Simple edit bindings for canvas text items
Table 19–9 Canvas operations that apply to text items
Window Items
Example 19–13 Using a canvas to scroll a set of widgets
Canvas Operations
Generating Postscript
Canvas Attributes
Large coordinate spaces
Scaling and Rotation
X Resources
Objects with many points
The send Command
The sender script
Using sender
Hooking the browser to a shell
Tk Widget Attributes 22
Borders and Relief
Table 22–2 Border and relief attribute resource names
The Focus Highlight
Padding and Anchors
Table 22–3 Border and relief attribute resource names
Putting It All Together
Color, Images, and Cursors 23
Colormaps and Visuals
Table 23–2 Visual classes for X displays. Values for the visual attribute
Bitmaps and Images
Example 23–3 Specifying an image attribute for a widget
The image Command
bimap images
The bitmap attribute
photo images
The Mouse Cursor
The Text Insert Cursor
Fonts and Text Attributes 24
Text Layout
Gridding, Resizing, and Geometry
Table 24–4 Geometry commands affected by gridding
Selection Attributes
A Font Selection Application
Example 24–11 Setting up the label and message widgets
Window Managers and Window Information 25
The wm Command
Size, placement, and decoration
Session state
Table 25–3 Session-related window manager operations
Table 25–4 Miscellaneous window manager operations
The winfo Command
Sending commands between applications
Example 25–2 Telling other applications what your name is
Family relationships
Table 25–5 Information useful with the send command
Table 25–6 Information about the window hierarchy
Virtual root window
Atoms and IDs
Table 25–9 Information associated with virtual root windows
Colormaps and visuals
Table 25–10 Information about atoms and window ids
Table 25–11 Information about colormaps and visual classes
The tk Command
A User Interface to bind 26
A Binding User Interface
Example 26–2 Bind_Display presents the bindings for a given widget or class
A Pair of Listboxes Working Together
Example 26–4 Controlling a pair of listboxes with one scrollbar
Example 26–5 Drag-scrolling a pair of listboxes together
The Editing Interface
Using X Resources 27
An Introduction To X Resources
Warning: order is important!
Loading Option Database Files
Adding Individual Database Entries
Accessing The Database
Managing User Preferences 28
App-Defaults Files
Defining Preferences
The Preferences User Interface
Managing The Preferences File
Tracing Changes To Preference Variables
C Programming and Tcl 29
Using the Tcl C Library
Application Structure
Tcl_Main and Tcl_AppInit
Example 29–1 A canonical Tcl main program and Tcl_AppInit
The standard main in Tcl 7.3
A C Command Procedure
Managing The Result’s Storage
Invoking Scripts From C
Bypassing Tcl_Eval
Putting A Tcl Program Together
An Overview of the Tcl C library
Application initialization
Creating and deleting interpreters
Creating and deleteing commands
Managing the result string
Lists and command parsing
Command pipelines
Tracing the actions of the Tcl interpreter
Evalutating Tcl commands
Manipulating Tcl variables
Evalutating expressions
Converting numbers
Hash tables
Dynamic Strings
Regular expressions and string matching
Tilde Substitution
Working with signals
C Programming and Tk 30
Tk_Main and Tcl_AppInit
A Custom Main Program
A Custom Event Loop
An Overview of the Tk C library
Parsing command line arguments
The standard application setup
Creating windows
Application name for send
Window coordinates
Window stacking order
Window information
Configuring widget attributes
Safe handling of the widget data structure
The selection and clipboard
Event bindings
Event loop interface
Handling X events
File handlers
Timer events
Idle callbacks
Reporting script errors
Handling X protocol errors
Using the X resource database
Managing bitmaps
Creating new image types
Using an image in a widget
Photo image types
Canvas object support
Geometry managment
String identifiers (UIDS)
Colors and Colormaps
Widget Instance Command
Example 31–5 ClockConfigure allocates resources for the widget
Displaying The Clock
The Window Event Procedure
Final Cleanup
Tcl Extension Packages 32
Extended Tcl
Adding tclX to your application
More UNIX system calls
File operations
New loop constructs
Command line addons
Debugging and development support
TCP/IP access
File scanning (i.e., awk)
Math functions as commands
List operations
Keyed list data structure
String utilities
XPG/3 message catalog
Memory debugging
Expect: Controlling Interactive Programs
The core expect commandsl
Pattern matching
Important variables
An example expect script
Debugging expect scripts
Expect’s Tcl debugger
The Dbg C interface
Tcl_AppInit With Extensions
Other Extensions
Porting to Tk 4.0 33
Obsolete Features
Scrollbar Interface
Pack info
Radio Buttons
Entry Widget
Text Widget
Color Attributes
0 of .
Results for:
No results containing your search query
P. 1


|Views: 275|Likes:

More info:

Published by: Yeshwanth Balakrishna on Apr 01, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





You're Reading a Free Preview
Pages 10 to 153 are not shown in this preview.
You're Reading a Free Preview
Pages 163 to 286 are not shown in this preview.
You're Reading a Free Preview
Pages 296 to 401 are not shown in this preview.
You're Reading a Free Preview
Pages 411 to 430 are not shown in this preview.
You're Reading a Free Preview
Pages 440 to 455 are not shown in this preview.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->