Effective TCL/TK Programming: Writing Better Programs with TCL and TK / Edition 1

Paperback (Print)
Buy New
Buy New from BN.com
$40.73
Used and New from Other Sellers
Used and New from Other Sellers
from $5.81
Usually ships in 1-2 business days
(Save 89%)
Other sellers (Paperback)
  • All (20) from $5.81   
  • New (7) from $39.69   
  • Used (13) from $5.81   

Overview

You need a graphical user interface, and it needs to run on multiple platforms. You don't have much time, and you're not a wizard with X/Motif, the Win32 GUI, or the Mac GUI. The project seems impossible, but with Tcl/Tk it's simple and fun.

The Tcl scripting language and the Tk toolkit create a powerful programming environment for building graphical user interfaces. With two lines of code you can create a simple button; with two hundred lines of code, a desktop calculator; and with a thousand lines of code, an industrial-strength groupware calendar and appointment minder. Your applications run on all of the major platforms: UNIX, Windows 95/NT, and Macintosh. You can even embed your programs in a Web page to make them available online.

Mark Harrison and Michael McLennan, two noted Tcl/Tk experts, combine their extensive experience in this practical programming guide. It is ideal for developers who are acquainted with the basics of Tcl/Tk and are now moving on to build real applications.

Effective Tcl/Tk Programming shows you how to build Tcl/Tk applications effectively and efficiently through plenty of real-world advice. It clarifies some of the more powerful aspects of Tcl/Tk, such as the packer, the canvas widget, and binding tags. The authors describe valuable design strategies and coding techniques that will make your Tcl/Tk projects successful. You will learn how to:

  • Create interactive displays with the canvas widget
  • Create customized editors with the text widget
  • Create new geometry managers, like tabbed notebooks or paned windows
  • Implement client/server architectures
  • Handle data structures
  • Interface with existing applications
  • Package Tcl/Tk code into reusable libraries
  • Deliver Tcl/Tk applications that are easy to configure and install
  • Embed applications in a Web page
  • Build applications that will run on multiple platforms

Throughout the book, the authors develop numerous applications and a library of reusable components. Learn from their approach, follow their strategies, and steal their code for your own applications! But don't bother retyping all of the examples.

0201634740B04062001

Read More Show Less

Product Details

  • ISBN-13: 9780201634747
  • Publisher: Addison-Wesley
  • Publication date: 11/28/1997
  • Series: Addison-Wesley Professional Computing Series
  • Edition description: New Edition
  • Edition number: 1
  • Pages: 432
  • Sales rank: 974,340
  • Product dimensions: 7.32 (w) x 8.89 (h) x 1.10 (d)

Meet the Author

Mark Harrison has been programming in Tcl ever since he heard John Ousterhout speak at the 1990 Usenix conference.* He currently works in the telecommunications industry for DSC Communications Corporation as a senior system architect, where he is Chief Tcl Evangelist.* In addition, he is enrolled in the computer science department at the University of Texas at Dallas.

Michael J. McLennan is a Distinguished Member of Technical Staff at Bell Labs Innovations for Lucent Technologies, where he develops software for Computer-Aided Design (CAD). He has been a Tcl/Tk enthusiast since 1992, writing many extensions and applications. He developed the incr Tcl extension, which adds object-oriented facilities to Tcl/Tk. He has also created several Tcl/Tk training courses.

0201634740AB04062001

Read More Show Less

Read an Excerpt

Preface It's easy to get started with Tcl/Tk. Just follow the steps in Appendix A to obtain the wish program and start it up. Then type in a few lines of code, like this: % button .b -text "Hello, World!" -command exit => .b % pack .b You'll see the Hello, World! button appear as soon as you enter the pack command. On Windows 95, it will look like this:

You don't have to edit any makefiles or fight with a compiler. You don't need to know everything about the X window system or the Microsoft Foundation Classes. You don't need to wade through pounds of confusing documents to find symbols, such as XA_FONT_NAME. Instead, you type a few lines of Tcl code and immediately see the results.

As you learn more about the Tk widgets, you can write lots of simple programs. With a text widget and 100 lines of Tcl code, you can put together a program for sending electronic mail (e-mail) messages. With a canvas widget and 200 lines of Tcl code, you can create a simple drawing editor.

A few other Tcl/Tk books will help you get started. John Ousterhout's Tcl and the Tk Toolkit starts with a complete overview of the Tcl language and then goes on to describe each of the Tk widgets. The book even describes how to add new functionality to Tcl/Tk by integrating your own C code into the wish program. Brent Welch's book Practical Programming in Tcl and Tk is another good source of Tcl/Tk code examples.

After reading one of the introductory Tcl/Tk books, you will be well acquainted with the nuts and bolts. But you may not have a good understanding of how they fit together to make an application.

We wrote this book to pick up where the others leave off. We assume that you understand some of the Tcl language and that you've written a few simple Tcl/Tk programs. If not, you can pick it up as you read along. But instead of explaining the basics, we focus on areas that are commonly misunderstood-such as the pack command, the bind mechanism, and the canvas widget. We not only explain how these things work but also show how you can use them to build powerful applications.

  • We explain how the packer works and then show how you can use it to create a tabbed notebook that displays "pages" of widgets.
  • We explain how binding tags work and then show how you can use them to handle the modes in a drawing editor.
  • We explain how the canvas works and then show how you can use it to build a progress gauge, a color wheel, and a calendar.

Along the way, we describe the lessons that we've learned from developing many thousands of lines of Tcl/Tk code. We show you software architectures and programming techniques that will make your Tcl/Tk code easier to maintain. For example, we show how to

  • Create client/server applications
  • Package Tcl/Tk code into libraries of reusable components
  • Use lists and arrays as data structures
  • Handle common quoting problems

Above all else, we try to present a holistic view of application development. In Chapter 1, we show you how to go about designing an application—from the initial concept to a working prototype to a finished product. Throughout the book, we develop several useful applications: a desktop calculator, a drawing editor, and a daily calendar that will store all of your appointments. In Chapter 8, we show you how to add polish to your finished applications and how to deliver them to customers.

In the course of this book, we develop more than two dozen useful components, including a toolbar, a paned window, a balloon help facility, and a confirmation dialog. We provide complete source code for these components in the software that accompanies this book. You can download this software from the site http://www.awl.com/cp/efftcl/efftcl.html. We encourage you to study these examples and to use them to build your own Tcl/Tk applications!

All of the examples in this book have been carefully designed to work with all recent versions of Tcl/Tk, including:

  • Tcl 7.5 / Tk 4.1
  • Tcl 7.6 / Tk 4.2
  • Tcl 8.0 / Tk 8.0

The examples should work with later releases as well. Most of our experience with Tcl/Tk comes from UNIX-based systems, so you will see a lot of references to UNIX throughout the book. But Tcl/Tk is not limited to UNIX systems. The Tcl 8.0 / Tk 8.0 release works cross-platform on UNIX, Windows 95/NT/3.1, and Macintosh systems. Almost all of our examples work identically on all three platforms. (Of course, some examples rely on such programs as /usr/lib/sendmail, which are available only on a UNIX system. Those examples will not work cross-platform without some modification.) Throughout the book, we've included screen snapshots from the various platforms to highlight the cross-platform capability. Acknowledgments Many people have made this book possible. Thanks to John Ousterhout and his team at Sun Microsystems for creating such a marvelous toolkit. Thanks to Mike Hendrickson and the staff at Addison Wesley Longman for their encouragement and support in producing this book. Thanks to Brian Kernighan for nudging us in the right direction and for his careful reviews and helpful comments. Thanks to Don Libes, Jeff Korn, Jeffrey Hobbs, and Jim Ingham for uncovering a number of weak spots in our material. Thanks to Evelyn Pyle for her meticulous proofreading and for smoothing out the wrinkles in our grammar. And thanks to all of the other reviewers who have made this work stronger: Ron Hutchins, Raymond Johnson, Steve Johnson, Oliver Jones, Joe Konstan, David Richardson, Alexei Rodriguez, and Win Treese.

Mark Harrison would like to thank his many colleagues at DSC Communications Corporation for their involvement and for their practical suggestions about incorporating Tcl into mission-critical products. In particular, Mark Ulferts and Kris Raney were especially helpful in this regard.

Michael McLennan would like to thank Sani Nassif for getting him started with Tcl/Tk; George Howlett for teaching him much of what he knows about software; John Tauke for making Tcl/Tk development a legitimate business activity at Bell Labs; Kishore Singhal, Prasad Subramaniam, and the management at Bell Labs for supporting this work; Joan Wendland, his friend and mentor; and Maria, Maxwell and Katie, for making him smile.

Mark Harrison Michael McLennan September 1997

Read More Show Less

Table of Contents

Preface
Ch. 1 Building Tcl/Tk Applications 1
Ch. 2 Packing, Gridding, and Placing Windows 15
Ch. 3 Handling Events 55
Ch. 4 Using the Canvas Widget 109
Ch. 5 Using the Text Widget 181
Ch. 6 Top-level Windows 233
Ch. 7 Interacting with Other Programs 263
Ch. 8 Delivering Tcl/Tk Applications 317
Ch. 9 Developing Cross-platform Applications 365
Appendix A: Getting Started with Tcl/Tk 389
Appendix B: Annotated Bibliography 393
Index 395
Read More Show Less

Preface

Preface

It's easy to get started with Tcl/Tk. Just follow the steps in Appendix A to obtain the wish program and start it up. Then type in a few lines of code, like this: % button .b -text "Hello, World!" -command exit => .b % pack .b You'll see the Hello, World! button appear as soon as you enter the pack command. On Windows 95, it will look like this:
You don't have to edit any makefiles or fight with a compiler. You don't need to know everything about the X window system or the Microsoft Foundation Classes. You don't need to wade through pounds of confusing documents to find symbols, such as XA_FONT_NAME. Instead, you type a few lines of Tcl code and immediately see the results.

As you learn more about the Tk widgets, you can write lots of simple programs. With a text widget and 100 lines of Tcl code, you can put together a program for sending electronic mail (e-mail) messages. With a canvas widget and 200 lines of Tcl code, you can create a simple drawing editor.

A few other Tcl/Tk books will help you get started. John Ousterhout's Tcl and the Tk Toolkit starts with a complete overview of the Tcl language and then goes on to describe each of the Tk widgets. The book even describes how to add new functionality to Tcl/Tk by integrating your own C code into the wish program. Brent Welch's book Practical Programming in Tcl and Tk is another good source of Tcl/Tk code examples.

After reading one of the introductory Tcl/Tk books, you will be well acquainted with the nuts and bolts. But you may not have a good understanding of how they fit together to make an application.

We wrote this book to pick up where the others leave off. We assume that you understand some of the Tcl language and that you've written a few simple Tcl/Tk programs. If not, you can pick it up as you read along. But instead of explaining the basics, we focus on areas that are commonly misunderstood-such as the pack command, the bind mechanism, and the canvas widget. We not only explain how these things work but also show how you can use them to build powerful applications.

  • We explain how the packer works and then show how you can use it to create a tabbed notebook that displays "pages" of widgets.
  • We explain how binding tags work and then show how you can use them to handle the modes in a drawing editor.
  • We explain how the canvas works and then show how you can use it to build a progress gauge, a color wheel, and a calendar.

Along the way, we describe the lessons that we've learned from developing many thousands of lines of Tcl/Tk code. We show you software architectures and programming techniques that will make your Tcl/Tk code easier to maintain. For example, we show how to

  • Create client/server applications
  • Package Tcl/Tk code into libraries of reusable components
  • Use lists and arrays as data structures
  • Handle common quoting problems

Above all else, we try to present a holistic view of application development. In Chapter 1, we show you how to go about designing an application--from the initial concept to a working prototype to a finished product. Throughout the book, we develop several useful applications: a desktop calculator, a drawing editor, and a daily calendar that will store all of your appointments. In Chapter 8, we show you how to add polish to your finished applications and how to deliver them to customers.

In the course of this book, we develop more than two dozen useful components, including a toolbar, a paned window, a balloon help facility, and a confirmation dialog. We provide complete source code for these components in the software that accompanies this book. You can download this software from the site http://www.awl.com/cp/efftcl/efftcl.html. We encourage you to study these examples and to use them to build your own Tcl/Tk applications!

All of the examples in this book have been carefully designed to work with all recent versions of Tcl/Tk, including:

  • Tcl 7.5 / Tk 4.1
  • Tcl 7.6 / Tk 4.2
  • Tcl 8.0 / Tk 8.0

The examples should work with later releases as well. Most of our experience with Tcl/Tk comes from UNIX-based systems, so you will see a lot of references to UNIX throughout the book. But Tcl/Tk is not limited to UNIX systems. The Tcl 8.0 / Tk 8.0 release works cross-platform on UNIX, Windows 95/NT/3.1, and Macintosh systems. Almost all of our examples work identically on all three platforms. (Of course, some examples rely on such programs as /usr/lib/sendmail, which are available only on a UNIX system. Those examples will not work cross-platform without some modification.) Throughout the book, we've included screen snapshots from the various platforms to highlight the cross-platform capability.

Acknowledgments

Many people have made this book possible. Thanks to John Ousterhout and his team at Sun Microsystems for creating such a marvelous toolkit. Thanks to Mike Hendrickson and the staff at Addison Wesley Longman for their encouragement and support in producing this book. Thanks to Brian Kernighan for nudging us in the right direction and for his careful reviews and helpful comments. Thanks to Don Libes, Jeff Korn, Jeffrey Hobbs, and Jim Ingham for uncovering a number of weak spots in our material. Thanks to Evelyn Pyle for her meticulous proofreading and for smoothing out the wrinkles in our grammar. And thanks to all of the other reviewers who have made this work stronger: Ron Hutchins, Raymond Johnson, Steve Johnson, Oliver Jones, Joe Konstan, David Richardson, Alexei Rodriguez, and Win Treese.

Mark Harrison would like to thank his many colleagues at DSC Communications Corporation for their involvement and for their practical suggestions about incorporating Tcl into mission-critical products. In particular, Mark Ulferts and Kris Raney were especially helpful in this regard.

Michael McLennan would like to thank Sani Nassif for getting him started with Tcl/Tk; George Howlett for teaching him much of what he knows about software; John Tauke for making Tcl/Tk development a legitimate business activity at Bell Labs; Kishore Singhal, Prasad Subramaniam, and the management at Bell Labs for supporting this work; Joan Wendland, his friend and mentor; and Maria, Maxwell and Katie, for making him smile.

Mark Harrison
Michael McLennan
September 1997

0201634740P04062001

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)