Learning Perl/Tk

Graphical User Interfaces with Perl

Nancy Walsh

Publisher: O'Reilly, 1999, 357 pages

ISBN: 1-56592-314-6

Keywords: TCLTk, Perl

Last modified: March 20, 2022, 5:11 p.m.

Perl/Tk is 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. Tk leberates Perl programmers from the world of command-line options, standard input and standard output, allowing them to build graphical event-driven applications for both Microsoft Windows and Unix.

Learning Perl/Tk is aimed at Perl novices and experts alike. It explains the reasoning behind event-driven applications, and offers 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 windows frame. For each of the commonly used Perl/Tk widgets, the book includes:

  • Introduction to the widget and its common usage, with examples
  • Configuration options
  • Methods for manipulating or fine-tuning the behavior of of the widget
  • Exercises to familiarize the reader with the widget and its applications

Although this book does not teach basic Perl, anyone who has written even the simplest Perl program should be able top 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 affects its presentation.

Learning Perl/Tk is for every Perl programmer who would like to implement simple, easy-to-user graphical interfaces.

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

Reviews

Learning Perl/Tk

Reviewed by Roland Buresund

OK ***** (5 out of 10)

Last modified: Nov. 15, 2008, 11:31 a.m.

This used to be the only book on the subject, but Nancy has written yet another one.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required