Book description
Perl/Tk is the marriage of the Tk graphical toolkit with Perl, the powerful programming language used primarily for system administration, web programming, and database manipulation. With Perl/Tk, you can build Perl programs with an attractive, intuitive GUI interface with all the power of Perl behind it.Mastering Perl/Tk is the "bible" of Perl/Tk: It's not only a great book for getting started, but the best reference for learning the techniques of experienced Perl/Tk programmers. The first half of the book contains the basics on how to use Perl/Tk, and then branches out into advanced applications with a series of extensive program examples. The result is a book accessible for novices, and invaluable for experienced programmers ready to learn the next step in the elegant and effective use of Perl/Tk. The book includes:
- An introduction to each of the basic Perl/Tk widgets and geometry managers
- A dissection of the MainLoop, including how to use callbacks and bindings effectively
- Coverage of the Tix widgets, an extended set of widgets that are a part of the standard Perl/Tk distribution
- Working with images in Perl/Tk, including bitmaps, pixmaps, photos, and how to compose a compound image type
- How to create custom mega-widgets in Perl/Tk, both composite and derived
- Handling interprocess communication with Perl/Tk, both with standard Unix utilities (pipes and sockets) and with the send command designed for direct communication between Tk applications
- Developing your own Tk widget in the C language
- Examples of web applications written with Perl/Tk and the LWP library
Publisher resources
Table of contents
- Mastering Perl/Tk
- A Note Regarding Supplemental Files
- Preface
- 1. Hello, Perl/Tk
-
2. Geometry Management
-
2.1. The pack Geometry Manager
- 2.1.1. Options for pack
- 2.1.2. Positioning Widgets
- 2.1.3. Allocation Rectangles
- 2.1.4. Filling the Allocation Rectangle
- 2.1.5. Expanding the Allocation Rectangle
- 2.1.6. Anchoring a Widget in Its Allocation Rectangle
- 2.1.7. Widget Order in the Window
- 2.1.8. Padding the Size of the Widget
- 2.1.9. Displaying in a Parent Other Than Your Own
- 2.1.10. Methods Associated with pack
- 2.1.11. Demo Programs for pack
-
2.2. The grid Geometry Manager
- 2.2.1. Special Characters
- 2.2.2. grid Options
- 2.2.3. Specifying Rows and Columns Explicitly
- 2.2.4. Spanning Rows and Columns Explicitly
- 2.2.5. Forcing a Widget to Fill a Cell
- 2.2.6. Padding the Widget
- 2.2.7. Specifying a Different Parent
- 2.2.8. Configuring Columns and Rows
- 2.2.9. Removing a Widget
- 2.2.10. Getting Information
- 2.2.11. Widget Location
- 2.2.12. How Many Columns and Rows?
- 2.2.13. gridSlaves
- 2.3. The place Geometry Manager
- 2.4. The form Geometry Manager
- 2.5. Geometry Management Summary
-
2.1. The pack Geometry Manager
- 3. Fonts
-
4. Button, Checkbutton, and Radiobutton Widgets
- 4.1. Creating Button Widgets
- 4.2. Standard Options for Each Button Type
- 4.3. Table of Options for Button-Type Widgets
- 4.4. Displaying Text on Buttons
- 4.5. Displaying an Image or Bitmap
- 4.6. Checkbutton and Radiobutton Indicator Status
- 4.7. On and Off Values for a Checkbutton
- 4.8. Radiobutton Values
- 4.9. The -command Option
- 4.10. Disabling a Button
- 4.11. Text Manipulation
- 4.12. Altering the Button’s Style
- 4.13. Changing the Size of a Button
- 4.14. Adding a Keyboard Mapping
- 4.15. Color Options
- 4.16. Indicator Colors
- 4.17. Hiding the Indicator
- 4.18. Focus Options
- 4.19. Altering the Highlight Rectangle
- 4.20. Configuring a Button
- 4.21. Flashing the Button
- 4.22. Invoking the Button
- 4.23. Turning a Checkbutton/Radiobutton On and Off
-
5. Label and Entry Widgets
- 5.1. The Label Widget
-
5.2. The Entry Widget
- 5.2.1. Creating the Entry Widget
- 5.2.2. Entry Options
- 5.2.3. Assigning the Entry’s Contents to a Variable
- 5.2.4. Relief
- 5.2.5. Entry Indexes
- 5.2.6. Text Selection Options
- 5.2.7. The Insert Cursor
- 5.2.8. Password Entries
- 5.2.9. Entry Widget Validation
- 5.2.10. Using a Scrollbar
- 5.2.11. Configuring an Entry Widget
- 5.2.12. Deleting Text
- 5.2.13. Getting the Contents of an Entry Widget
- 5.2.14. Moving the Insertion Cursor
- 5.2.15. Getting a Numeric Index Value
- 5.2.16. Inserting Text
- 5.2.17. Scanning Text
- 5.2.18. Working with the Selection
- 5.2.19. Changing the View in the Entry Widget
- 5.3. The Perl/Tk LabEntry Mega-Widget
-
6. The Scrollbar Widget
- 6.1. Defining Scrollbar Parts
- 6.2. The Scrolled Method
-
6.3. The Scrollbar Widget
- 6.3.1. Creating a Scrollbar Widget
- 6.3.2. Scrollbar Options
- 6.3.3. Scrollbar Colors
- 6.3.4. Scrollbar Style
- 6.3.5. Scrollbar Orientation
- 6.3.6. Using the Arrows and the Slider
- 6.3.7. Assigning a Callback
- 6.3.8. How the Scrollbar Communicates with Other Widgets
- 6.3.9. Scrollbar Configuration
- 6.3.10. Defining What We Can See
- 6.3.11. Getting the Current View
- 6.3.12. Activating Elements in a Scrollbar
- 6.3.13. Calculating Change from Pixels
- 6.3.14. Locating a Point in the Trough
- 6.3.15. Identifying Elements
- 6.4. Examples
-
7. The Listbox Widget
- 7.1. Creating and Filling a Listbox
- 7.2. Listbox Options
- 7.3. Selection Modes
- 7.4. Colors
- 7.5. Listbox Style
- 7.6. Configuring a Listbox
- 7.7. Inserting Items
- 7.8. Deleting Items
- 7.9. Retrieving Elements
- 7.10. Selection Methods
- 7.11. Moving to a Specific Index
- 7.12. Translating Indexes
- 7.13. Counting Items
- 7.14. Active Versus Selected
- 7.15. Bounding Box
- 7.16. Finding an Index by y Coordinate
- 7.17. Scrolling Methods
- 7.18. Listbox Virtual Events
- 7.19. Listbox Example
-
8. The Text, TextUndo,and ROText Widgets
- 8.1. Creating and Using a Text Widget
- 8.2. Text Widget Options
- 8.3. A Short Break for a Simple Example
- 8.4. Text Indexes
-
8.5. Text Tags
- 8.5.1. Tag Options
- 8.5.2. A Simple Tag Example
- 8.5.3. Selections in a Text Widget Using the “sel” Tag
- 8.5.4. Configuring and Creating Tags
- 8.5.5. Adding a Tag to Existing Text
- 8.5.6. Using bind with Tags
- 8.5.7. Deleting All Instances of a Tag
- 8.5.8. Removing a Tag from the Text
- 8.5.9. Raising and Lowering Tags
- 8.5.10. Getting Tag Names
- 8.5.11. Determining Where a Tag Applies
- 8.6. Inserting Text
- 8.7. Deleting Text
- 8.8. Retrieving Text
- 8.9. Translating Index Values
- 8.10. Comparing Index Values
- 8.11. Showing an Index
- 8.12. Getting the Size of a Character
- 8.13. Getting Line Information
- 8.14. Searching the Contents of a Text Widget
- 8.15. Scrolling
- 8.16. Marks
- 8.17. Embedding Widgets
- 8.18. Internal Debug Flag
- 8.19. The Perl/Tk Text Widget Extended Methods
- 8.20. The TextUndo Widget
- 8.21. The ROText Widget
-
9. The Canvas Widget
- 9.1. Creating a Canvas
- 9.2. The Canvas Coordinate System
- 9.3. The Scrollable Region
- 9.4. Using bind with a Canvas
- 9.5. Canvas Options
- 9.6. Creating Items in a Canvas
- 9.7. Configuring the Canvas Widget
- 9.8. Configuring Items in the Canvas Widget
- 9.9. Tags
- 9.10. Retrieving Bounding Box Coordinates
- 9.11. Translating Coordinates
- 9.12. Moving Items Around
- 9.13. Changing the Display List
- 9.14. Deleting Items
- 9.15. Deleting Tags
- 9.16. Determining Item Type
- 9.17. Setting Keyboard Focus
- 9.18. Rendering the Canvas as PostScript
- 9.19. Scaling the Canvas
- 9.20. Scanning
- 9.21. A Drawing Program Example
-
10. The Scale Widget
- 10.1. Creating a Scale
- 10.2. Assigning a Callback
- 10.3. Orientation
- 10.4. Minimum and Maximum Values
- 10.5. Displayed Versus Stored Value
- 10.6. Adding a Label
- 10.7. Displaying Value Increments
- 10.8. Changing the Size of the Scale
- 10.9. Options You’ll Probably Never Need
- 10.10. Configuring a Scale
- 10.11. Getting the Value of a Scale
- 10.12. Setting the Value of a Scale
- 10.13. Determining Coordinates
- 10.14. Identifying Parts of a Scale
-
11. Frame, MainWindow,and Toplevel Widgets
- 11.1. Creating a Frame
- 11.2. Creating a Toplevel Widget
- 11.3. Options
- 11.4. Frame Methods
-
11.5. Toplevel Methods
- 11.5.1. Sizing a Toplevel
- 11.5.2. Maximum Size
- 11.5.3. Minimum Size
- 11.5.4. Limiting Resizing
- 11.5.5. Using a Size Aspect
- 11.5.6. Setting the Title
- 11.5.7. Showing the Toplevel
- 11.5.8. Withdrawing the Toplevel
- 11.5.9. Iconifying the Toplevel
- 11.5.10. Specifying the Icon Bitmap
- 11.5.11. Specifying the Icon Mask
- 11.5.12. Setting the Name of the Icon
- 11.5.13. Setting the Icon Position
- 11.5.14. Using a Window Instead of an Icon
- 11.5.15. Determining the State
- 11.5.16. Assigning a Client Name
- 11.5.17. Window Properties
- 11.5.18. The Colormap Property
- 11.5.19. The Command Property
- 11.5.20. The Focus Model
- 11.5.21. Getting a Widget’s Window ID
- 11.5.22. The Application Grid
- 11.5.23. Being the Leader
- 11.5.24. Removing Decorations
- 11.5.25. Who Placed the Window?
- 11.5.26. Who Sized It?
- 11.5.27. Transient Windows
- 11.6. Creating Multiple MainWindows
- 11.7. Putting Two MainWindows to Work
- 12. The Menu System
-
13. Miscellaneous Perl/Tk Methods
- 13.1. Managing Widgets with configure and cget
- 13.2. Building a Family Tree
- 13.3. Widget’s ID
- 13.4. Color-Related Methods
- 13.5. The Application’s Name
- 13.6. Widget Existence
- 13.7. Is the Widget Mapped?
- 13.8. Converting Screen Distances
- 13.9. Size of Widget
- 13.10. Widget Position
- 13.11. Screen Information
- 13.12. Atom Methods
- 13.13. Ringing a Bell
- 13.14. Clipboard and Selection Methods
- 13.15. Destroying a Widget
- 13.16. Focus Methods
- 13.17. Grab Methods
- 13.18. Marking a Widget Busy and Unbusy
- 13.19. Widget Mapping and Layering
- 13.20. Interapplication Communication
- 13.21. Waiting for Events to Happen
- 13.22. Time Delays
- 13.23. Parsing Command-Line Options
- 13.24. Really Miscellaneous Methods
-
14. Creating Custom Widgets in Pure Perl/Tk
- 14.1. A Mega-Widget Quick-Start
- 14.2. The Perl/Tk Class Hierarchy
-
14.3. Mega-Widget Implementation Details
- 14.3.1. Tk::Widget::new, the Real Perl/Tk Widget Constructor
- 14.3.2. Subroutine ClassInit
- 14.3.3. Subroutine CreateArgs
- 14.3.4. Subroutine SetBindtags
- 14.3.5. Subroutine Populate
- 14.3.6. Subroutine ConfigSpecs
- 14.3.7. Subroutine Delegates
- 14.3.8. Other Useful Methods
- 14.3.9. Mega-Widget Instance Variables
- 14.4. Composite Mega-Widgets
- 14.5. Derived Mega-Widgets
- 14.6. Packaging a Mega-Widget for Public Distribution
-
15. Anatomy of the MainLoop
- 15.1. Creating a Callback
- 15.2. Binding to Events
- 15.3. The bindtags Command
- 15.4. Executing Nonblocking System Commands
- 15.5. Tracing Perl/Tk Variables
- 15.6. Nonblocking Wait Activities
- 15.7. Splash Screens
- 15.8. Synthesizing Virtual Events
- 15.9. Coexisting with Other GUI Main Loops
- 16. User Customization
-
17. Images and Animations
- 17.1. An Overview of Perl/Tk Image Types
- 17.2. Methods Common to All Image Types
- 17.3. Bitmap Primitives
- 17.4. DefineBitmap
- 17.5. The Bitmap Image Type
- 17.6. The Pixmap Image Type
- 17.7. The Photo Image Type
- 17.8. The Compound Image Type
- 17.9. Tk::Animation
- 17.10. tkneko—Animating the Neko on a Canvas
- 17.11. Tile and Transparent Images
- 17.12. Miscellaneous Image Methods
- 17.13. Simple Photo Rotations
- 18. A Tk Interface Extension Tour
- 19. Interprocess Communicationwith Pipes and Sockets
- 20. IPC with send
-
21. C Widget Internals
-
21.1. The Tk::Square Widget
- 21.1.1. Tcl/Tk Example
- 21.1.2. Overview of the Perl/Tk Distribution
-
21.1.3. Layout of a Typical C Widget
- 21.1.3.1. Tk::Square instance structure
- 21.1.3.2. Tk::Square configuration specifications
- 21.1.3.3. Tk::Square instance constructor
- 21.1.3.4. Tk::Square method processors
- 21.1.3.5. Tk::Square option configurator
- 21.1.3.6. Tk::Square event handler
- 21.1.3.7. Tk::Square drawing handler
- 21.1.3.8. Tk::Square destructor
- 21.2. Interfacing tkSquare.c with Perl/Tk
- 21.3. Building and Testing Tk::Square
- 21.4. How Not to Port Tk::Square
-
21.1. The Tk::Square Widget
-
22. Perl/Tk and the Web
- 22.1. Library for WWW Access in Perl
- 22.2. The PerlPlus Browser Plug-in
-
23. Plethora of pTk Potpourri
- 23.1. pTk Special Variables and Exporter Symbols
- 23.2. Manipulating the Cursor
- 23.3. Dialog Boxes
- 23.4. The Adjuster Widget
- 23.5. The Balloon Widget
- 23.6. The BrowseEntry Widget
- 23.7. The LabFrame Widget
- 23.8. The NoteBook Widget
- 23.9. The Pane Widget
- 23.10. The ProgressBar Widget
- 23.11. Widgets Not in the Perl/Tk Distribution
- A. Installing Perl/Tk
-
B. Options and Default Valuesfor Each Widget
- B.1. Adjuster
- B.2. Balloon
- B.3. Bitmap
- B.4. BrowseEntry
- B.5. Button
- B.6. Canvas
- B.7. Checkbutton
- B.8. ColorEditor
- B.9. Dialog
- B.10. DirTree
- B.11. Entry
- B.12. ErrorDialog
- B.13. FileSelect
- B.14. Frame
- B.15. HList
- B.16. Label
- B.17. LabEntry
- B.18. LabFrame
- B.19. Listbox
- B.20. MainWindow
- B.21. Menu
- B.22. Menubutton
- B.23. Message
- B.24. NoteBook
- B.25. Optionmenu
- B.26. Pane
- B.27. Photo
- B.28. ProgressBar
- B.29. Radiobutton
- B.30. ROText
- B.31. Scale
- B.32. Scrollbar
- B.33. Table
- B.34. Text
- B.35. TextUndo
- B.36. Tiler
- B.37. TList
- B.38. Toplevel
- B.39. Tree
- C. Complete Program Listings
- Index
- About the Authors
- Colophon
- Copyright
Product information
- Title: Mastering Perl/Tk
- Author(s):
- Release date: January 2002
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781565927162
You might also like
book
Learning Perl/Tk
Learning Perl/Tk is a tutorial for Perl/Tk, the extension to Perl for creating graphical user interfaces. …
book
Perl/Tk Pocket Reference
The Perl/Tk Pocket Reference is a companion volume to Learning Perl/Tk, an O'Reilly Animal Guide. Learning …
book
X Window System User's Guide for X11 R3 and R4 of the X Window System
The X Window System User's Guide orients the new user to window system concepts and provides …
book
Web, Graphics & Perl/Tk Programming
In its first five years of existence, The Perl Journal (TPJ) became the voice of the …