Book HomeMastering Perl/TkSearch this book

Chapter 23. Plethora of pTk Potpourri

Contents:

pTk Special Variables and Exporter Symbols
Manipulating the Cursor
Dialog Boxes
The Adjuster Widget
The Balloon Widget
The BrowseEntry Widget
The LabFrame Widget
The NoteBook Widget
The Pane Widget
The ProgressBar Widget
Widgets Not in the Perl/Tk Distribution

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:

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'):



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.