Chapter 23. Plethora of pTk Potpourri
In this chapter, we present a blast of miscellaneous widgets,
methods, options, and cookbook ideas. There isn't a lot of
depth in this chapter, just a jumble of material that didn't
fit in the rest of the book, but that we know you'll need some
This chapter covers:
Perl/Tk special variables and exporter symbols
Cursor manipulation and customization
Using dialogs for messages, errors, selecting colors, or opening and
The Adjuster widget, which allows users to resize frames in an
Calling up "help" windows via the Balloon widget
The BrowseEntry widget, which is a composite of the Entry widget and
The LabFrame widget, which is a Frame with a label attached
The NoteBook widget, which is a simple way to create multiple pages
The Pane widget, essentially a scrollable Frame
The ProgressBar widget, which can be used to display progress to a
user during a time-consuming operation
23.1. pTk Special Variables and Exporter Symbols
Before we get to the interesting stuff, we need to list the special
variables and symbols unique to Perl/Tk.
23.1.1. Global Variables
global variables are available for your use:
Perl/Tk version, which incorporates the Tcl/Tk version it's
based upon, plus the Perl/Tk subrelease number.
'800.023' is the 23rd Perl/Tk release based on
Tcl/Tk 8.0. '803.xxx' will be based on Tcl/Tk 8.3.
pathname where the Tk modules are installed; for example:
platform, which is 'MSWin32' for Win32 machines,
base Tcl/Tk version, for example '8.0'.
Tcl/Tk patch level, for example '8.0'.
flag to force Tk to use pure Motif style windows.
23.1.2. Symbols Exported by Default
The use Tk statement exports these subroutines by
Handles Tk events. See Chapter 15, "Anatomy of the MainLoop".
callback definitions to delay argument evaluation. See Chapter 15, "Anatomy of the MainLoop".
Perl's CORE::exit to clean up Tk data
that $widget is a valid Perl/Tk widget reference.
Starts the Tk event loop.
23.1.3. Optionally Exported Symbols
You can import these symbols if desired:
block of code, trapping and ignoring any errors. The code should be
enclosed in a Perl block: catch
version of a callback's event structure. See Chapter 15, "Anatomy of the MainLoop".
a list for an exact string match. It returns the ordinal of the
match, or -1 if no match. For example: my
lsearch(\@Selection,$i). The first argument is an
array reference and the second the match string.
Operation subroutine, commonly used to disable a callback.
The XS version.
version of the widget that owns the callback. See Chapter 15, "Anatomy of the MainLoop".
- DONT_WAIT, WINDOW_EVENTS, FILE_EVENTS, TIMER_EVENTS, IDLE_EVENTS, ALL_EVENTS
DoOneEvent bit patterns. See Chapter 15, "Anatomy of the MainLoop".
- NORMAL_BG, ACTIVE_BG, SELECT_BG, SELECT_FG, TROUGH, INDICATOR, DISABLED, BLACK, WHITE
23.1.4. Exporter Tags
You can import several symbols at once using an Exporter tag (for
example, to get all the DoOneEvent bit patterns,
do use Tk ':eventtypes'):
=> qw/DONT_WAIT WINDOW_EVENTS
FILE_EVENTS TIMER_EVENTS IDLE_EVENTS ALL_EVENTS/
:variables => qw/*widget
:colors => qw/NORMAL_BG
ACTIVE_BG SELECT_BG SELECT_FG TROUGH INDICATOR
DISABLED BLACK WHITE/