start page | rating of books | rating of authors | reviews | copyrights
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
day.
This chapter covers:
-
Perl/Tk special variables and exporter symbols
-
Cursor manipulation and customization
-
Using dialogs for messages, errors, selecting colors, or opening and
saving files
-
The Adjuster widget, which allows users to resize frames in an
application
-
Calling up "help" windows via the Balloon widget
-
The BrowseEntry widget, which is a composite of the Entry widget and
a Listbox
-
The LabFrame widget, which is a Frame with a label attached
-
The NoteBook widget, which is a simple way to create multiple pages
with tabs
-
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
These
global variables are available for your use:
- $Tk::VERSION
-
The
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.
- $Tk::library
-
The
pathname where the Tk modules are installed; for example:
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux/Tk.
- $Tk::platform
-
The
platform, which is 'MSWin32' for Win32 machines,
otherwise 'unix'.
- $Tk::version
-
The
base Tcl/Tk version, for example '8.0'.
- $Tk::patchLevel
-
The
Tcl/Tk patch level, for example '8.0'.
- $Tk::strictMotif
-
A
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
default:
- DoOneEvent
-
Handles Tk events. See Chapter 15, "Anatomy of the MainLoop".
- Ev
-
Used in
callback definitions to delay argument evaluation. See Chapter 15, "Anatomy of the MainLoop".
- exit
-
Overrides
Perl's CORE::exit to clean up Tk data
structures.
- Exists($widget)
-
Ensures
that $widget is a valid Perl/Tk widget reference.
- MainLoop
-
Starts the Tk event loop.
- tkinit(@args)
-
Shorthand
for MainWindow->new(@args).
23.1.3. Optionally Exported Symbols
You can import these symbols if desired:
- catch
-
Executes a
block of code, trapping and ignoring any errors. The code should be
enclosed in a Perl block: catch
{$widget->cget(-state)}.
- *event
-
A localized
version of a callback's event structure. See Chapter 15, "Anatomy of the MainLoop".
- lsearch
-
Searches
a list for an exact string match. It returns the ordinal of the
match, or -1 if no match. For example: my
$ord =
lsearch(\@Selection,$i). The first argument is an
array reference and the second the match string.
- NoOp
-
A No
Operation subroutine, commonly used to disable a callback.
- $XS_VERSION
-
The XS version.
- *widget
-
A localized
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
-
Common colors.
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'):
-
:eventtypes
=> qw/DONT_WAIT WINDOW_EVENTS
FILE_EVENTS TIMER_EVENTS IDLE_EVENTS ALL_EVENTS/
-
:variables => qw/*widget
*event/
-
:colors => qw/NORMAL_BG
ACTIVE_BG SELECT_BG SELECT_FG TROUGH INDICATOR
DISABLED BLACK WHITE/
| | |
22.2. The PerlPlus Browser Plug-in | | 23.2. Manipulating the Cursor |
Copyright © 2002 O'Reilly & Associates. All rights reserved.