Learning Perl/Tk

Book description

Learning Perl/Tk is a tutorial for Perl/Tk, the extension to Perl for creating graphical user interfaces. With Tk, Perl programs can be window-based rather than command-line based, with buttons, entry fields, listboxes, menus, and scrollbars. Originally developed for the Tcl language, the Perl port of the Tk toolkit liberates Perl programmers from the world of command-line options, STDIN, and STDOUT, allowing them to build graphical, event-driven applications for both Windows and UNIX. This book is aimed at Perl novices and experts alike. It explains the reasoning behind event-driven applications and drills in guidelines on how to best design graphical applications. It teaches how to implement and configure each of the Perl/Tk graphical elements step-by-step. Special attention is given to the geometry managers, which are needed to position each button, menu, label and listbox in the window frame. Although this book does not teach basic Perl, anyone who has written even the simplest Perl program should be able to learn Tk from this book. The writing is breezy and informal, and gets right to the point of what you need to know and why. The book is rife with illustrations that demonstrate how each element is drawn and how its configuration options affect its presentation. Learning Perl/Tk is for every Perl programmer who would like to implement simple, easy-to-use graphical interfaces.

Publisher resources

Download Example Code

Table of contents

  1. Copyright
  2. Preface
    1. What You Should Already Know
    2. What's in This Book
    3. Reading Order
    4. Typographical Conventions
    5. We'd Like to Hear from You
    6. Acknowledgments
  3. Introduction to Perl/Tk
    1. A Bit of History About Perl (and Tk)
    2. Perl/Tk for Both Unix and Windows 95/NT
    3. Why Use a Graphical Interface?
    4. Why Use Perl/Tk?
    5. Installing the Tk Module
    6. Creating Widgets
    7. Coding Style
    8. Displaying a Widget
    9. The Anatomy of an Event Loop
    10. Hello World Example
    11. Using exit Versus Using destroy
    12. Naming Conventions for Widget Types
    13. Using print for Diagnostic/Debugging Purposes
    14. Designing Your Windows (A Short Lecture)
  4. Geometry Management
    1. Pack
    2. Grid
    3. Place
    4. Geometry Management Summary
  5. The Basic Button
    1. The Button Widget
    2. Some Fun Things to Try
  6. Checkbuttons and Radiobuttons
    1. The Checkbutton Widget
    2. The Radiobutton Widget
    3. Fun Things to Try
  7. Label and Entry Widgets
    1. The Label Widget
    2. The Entry Widget
    3. Fun Things to Try
  8. Scrollbars
    1. Defining Scrollbar Parts
    2. The Scrolled Method
    3. The Scrollbar Widget
    4. Examples
    5. Fun Things to Try
  9. The Listbox Widget
    1. Creating and Filling a Listbox
    2. Listbox Options
    3. Selection Modes
    4. Colors
    5. Listbox Style
    6. Configuring a Listbox
    7. Inserting Items
    8. Deleting Items
    9. Retrieving Elements
    10. Selection Methods
    11. Moving to a Specific Index
    12. Translating Indexes
    13. Counting Items
    14. Active Versus Selected
    15. Bounding Box
    16. Finding an Index by Y Coordinate
    17. Scrolling Methods
    18. Listbox Example
    19. Fun Things to Try
  10. The Text Widget
    1. Creating and Using a Text Widget
    2. Text Widget Options
    3. A Short Break for a Simple Example
    4. Text Indexes
    5. Text Tags
    6. Inserting Text
    7. Deleting Text
    8. Retrieving Text
    9. Translating Index Values
    10. Comparing Index Values
    11. Showing an Index
    12. Getting the Size of a Character
    13. Getting Line Information
    14. Searching the Contents of a Text Widget
    15. Scrolling
    16. Marks
    17. Embedding Widgets
    18. Internal Debug Flag
    19. Fun Things to Try
  11. The Canvas Widget
    1. Creating a Canvas
    2. Coordinate System
    3. The Scrollable Region
    4. Using Bind with a Canvas
    5. Canvas Options
    6. Creating Items in a Canvas
    7. Configuring the Canvas Widget
    8. Configuring Items in the Canvas Widget
    9. Tags
    10. Retrieving Bounding Box Coordinates
    11. Translating Coordinates
    12. Moving Items Around
    13. Changing the Display List
    14. Deleting Items
    15. Deleting Tags
    16. Determining Item Type
    17. Set Keyboard Focus
    18. Rendering the Canvas as PostScript
    19. Scaling the Canvas
    20. Scanning
    21. A Drawing Program Example
    22. Fun Things to Try
  12. The Scale Widget
    1. Creating a Scale
    2. Assigning a Callback
    3. Orientation
    4. Minimum and Maximum Values
    5. Displayed Versus Stored Value
    6. Adding a Label
    7. Displaying Value Increments
    8. Changing the Size of the Scale
    9. Options You'll Probably Never Need
    10. Configuring a Scale
    11. Getting the Value of a Scale
    12. Setting the Value of a Scale
    13. Determining Coordinates
    14. Identifying Parts of a Scale
    15. Fun Things to Try
  13. Menus
    1. Different Types of Menus
    2. The Menubutton Widget
    3. Complete Menubutton Examples
    4. The Menu Widget
    5. Optionmenu Widget
    6. Fun Things to Try
  14. Frames
    1. Creating a Frame
    2. Frame Style
    3. Frames Aren't Interactive
    4. Colormap Complications
    5. Frame Methods
    6. Fun Things to Try
  15. Toplevel Widgets
    1. Creating a Toplevel Widget
    2. Toplevel Methods
    3. Review
    4. Fun Things to Try
  16. Binding Events
    1. The bind Method
    2. Arguments Sent to the Callback
    3. Defining Event Sequences
    4. Event Information
    5. Bailing Out of a Callback Created with bind
    6. The bindtags Method
    7. Ways to Use bind
  17. Composite Widgets
    1. Looking at an Example Sideways
    2. Location of Files
    3. Creating a Composite Widget Based on Frame
    4. Toplevel-Based Composite Widgets
  18. Methods for Any Widget
    1. Building a Family Tree
    2. Color-Related Methods
    3. Option Databases
    4. The Application's Name
    5. Widget Existence
    6. Is the Widget Mapped?
    7. Converting Screen Distances
    8. Size of Widget
    9. Widget Position
    10. Screen Information
    11. Atom Methods
    12. Ringing a Bell
    13. Clipboard Methods
    14. Selection Methods
    15. Destroying a Widget
    16. Focus Methods
    17. Grab Methods
    18. Interapplication Communication
    19. Waiting for Events to Happen
    20. Parsing Command-Line Options
    21. Time Delays
  19. Configuring Widgets with configure and cget
    1. The configure Method
    2. Default Values for Each Widget in Table Form
  20. Operating System Differences
    1. Unix
    2. Windows NT and 95
  21. Fonts
    1. The Font String
    2. Font Methods
  22. Colophon
  23. Index

Product information

  • Title: Learning Perl/Tk
  • Author(s): Nancy Walsh
  • Release date: January 1999
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781565923140