Free Sample
+ Collection

Tcl/Tk 8.5 Programming Cookbook

Bert Wheeler

With over 100 recipes, this Cookbook is ideal for both beginners and advanced Tcl/Tk programmers. From the basics to creating applications, it’s full of indispensable tips and tricks to make the most of the language.
RRP $23.99
RRP $39.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849512985
Paperback236 pages

About This Book

  • The quickest way to solve your problems with Tcl/Tk 8.5
  • Understand the basics and fundamentals of the Tcl/Tk 8.5 programming language
  • Learn graphical User Interface development with the Tcl/Tk 8.5 Widget set
  • Get a thorough and detailed understanding of the concepts with a real-world address book application
  • Each recipe is a carefully organized sequence of instructions to efficiently learn the features and capabilities of the Tcl/Tk 8.5 language

Who This Book Is For

If you are a beginner interested in adding Tcl/Tk 8.5 to your list of languages, or an experienced Tcl/Tk programmer looking to sharpen your knowledge, be assured, you will find your prefect guide in this book. Whether you are developing for your personal use or commercial applications, this book will provide you with a ready reference to the building blocks of Tcl/Tk 8.5

Table of Contents

Chapter 1: The Tcl Shell
The Tcl shell
Writing to the Tcl console
Mathematical expressions
Tcl expr operands
Mathematical functions
Computing mathematical expressions
Referencing files in Tcl
Command line arguments
Chapter 2: Using the Building Blocks Control Constructs
Controlling flow with the if statement
Looping with for
Looping with foreach
Looping with while
Continuing a procedure
Breaking out of a procedure
Nested looping
Chapter 3: Error Handling
Using the catch command
Using the eval command
Using the error command
Error handling procedure
Chapter 4: Handling String Expressions
Appending to a string
Formatting a string
Matching a regular expression within a string
Performing character substitution on a string
Parsing a string using conversion specifiers
Determining the length of a string
Comparing strings
Comparing a string of characters
Locating the first instance of a character
Locating the index of a character
Determining the class of a string
Locating the last instance of a string
Determining the size of a string
Replacing values within a string
Locating a pattern within a string
Returning a range of characters from a string
Creating a string of repeated characters
Replacing ranges of characters contained within a string
Creating a reverse string
Converting a string to lowercase
Converting a string to title
Converting a string to uppercase
Trimming a string
Trimming leading whitespace
Trimming trailing whitespace
Locating the word end
Locating the word start
Performing variable substitution
Chapter 5: Expanding String Functionality Using Lists
Creating a list
Joining two lists
Joining list elements
Appending list elements
Assigning list elements to variables
Retrieving an element from a list
Inserting elements into a list
Determining the number of elements
Getting a list element
Repeating elements
Replacing elements
Reversing elements
Searching a list
Editing a list
Sorting a list
Splitting a string into a list
Chapter 6: The Tcl Dictionary
Creating a dictionary
Appending to a dictionary
Determining if a key exists
Filtering a dictionary
Searching a dictionary
Getting a record
Incrementing a value
Getting the dictionary structure
Getting a list of keys
Appending to an existing record
Merging two dictionaries
Creating a blank dictionary structure
Updating variables from a dictionary
Determining the size of a dictionary
Getting all records
Assigning values
Chapter 7: File Operations
Opening a file
Configuring a file
Opening a command pipeline
Writing a file
Reading a file
Closing a file
File handling
Chapter 8: Tk GUI Programming with Tcl/Tk
Creating a widget
Writing to the console
Setting the attributes of the window through window manager
Creating an additional window
Chapter 9: Configuring and Controlling Tk Widgets
Creating a frame widget
Creating a label widget
Creating an entry widget
Creating a button widget
Creating a listbox widget
Creating an image
Creating a simple form
Chapter 10: Geometry Management
Controlling layout with the pack command
Controlling layout with the grid command
Combining pack and grid
Creating an address book interface
Chapter 11: Using Tcl Built-in Dialog Windows
Displaying a message box
Displaying a confirmation dialog
Displaying the color picker
Displaying the directory dialog
Displaying the file selection dialog
Selecting a directory and file
Chapter 12: Creating and Managing Menus
Creating a menu
Adding menu buttons
Displaying a pop-up menu
Data entry application
Chapter 13: Creating the Address Book Application
Creating the Address Book application
Adding a record
Navigating records
Deleting a record
Finding a record
Full listing

What You Will Learn

  • Expand your Tcl/Tk abilities by gaining in-depth knowledge of the core commands
  • Learn efficient programming by using control constructs in your program
  • Handle numerous types of string expressions by performing formatting, searches, and advanced manipulations on them
  • Gain expertise in using lists with examples teaching you the various available operations
  • Demystify the Tcl Dictionary and learn how it can be a viable substitute for a third-party database
  • Perform various operations on the dictionary elements in both single and multiple layer dictionaries
  • Create, manage, and empower your Graphical User Interface with Tk window management, to develop attractive applications
  • Ease your file system access with an in-depth study of File operations
  • Perform advanced error trapping and recovery with error handling commands in Tcl

In Detail

With Tcl/Tk, you can create full-featured cross-platform applications in a simple and easy-to-understand way without any expensive development package; the only tools required are a simple text editor and your imagination. This practical cookbook will help you to efficiently interact with editors, debuggers, and shell type interactive programs using Tcl/Tk 8. This cookbook will comprehensively guide you through practical implementation of Tcl/Tk 8.5 commands and tools.

This book will take you through all the steps needed to become a productive programmer in Tcl/Tk 8. Right from guiding you through the basics to creating a stand-alone application, it provides complete explanation of all the steps along with handy tips and tricks.

The book begins with an introduction to the Tcl shell, syntax, variables, and programming best practices in the language. It then explores procedures and the flow of events with control constructs followed by advanced error trapping and recovery. From Chapter 4, a detailed study of string expressions and handling enables you to handle various string functions and use lists to expand the string functionality. The book then discusses in-depth the Tcl Dictionary and how to utilize it to store and retrieve data. File operations and Tk GUI handling are covered extensively along with a developing a real-world address book application to practice the concepts learned.


Read More

Recommended for You

Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications
$ 29.99
WCF 4.0 Multi-tier Services Development with LINQ to Entities
$ 29.99