Geometry management is probably the most important concept in using
Perl/Tk. It determines how your widgets are drawn on the screen. Four
geometry managers—pack,
grid, place, andform — are covered here. Most of
the examples in the book use pack.
You can easily make effective use of fonts in your Perl/Tk
applications using Font objects. This chapter shows you how to
utilize Fonts and what options are available for changing them.
Several small applications are covered that demonstrate the use of
Fonts.
The Button widget is the first we cover, and we supply lots of
details. There are tons of code snippets and screen shots showing
different ways to manipulate the Button widget. Many of the options
we discuss are common among the other standard widgets. In addition
to the standard Button widget, we'll look at two derived
variants: the Checkbutton and Radiobutton widgets.
The Label widget is the simplest of all. It is usually used with an
Entry widget, which is why they are included in the same chapter.
Typically, the Entry widget accepts user input, and the Label
identifies the input. Perl/Tk has a special Tk::LabEntry widget that
we'll examine in detail.
Certain widgets in Perl/Tk can be scrolled, which means they can
contain more information than you can see on the screen. Scrollbars
are used to navigate the data inside these widgets. This chapter
tells you how Scrollbars communicate with each widget and how to
create and use them. It also illustrates the
Scrolled method, which automates Scrollbar
creation.
A Listbox widget can contain any sort of data, but it usually
contains a list of options from which the user can select. In this
chapter, you'll learn how to create a Listbox, fill it with
some items, and change the way the user selects items from the list.
The Text widget is a versatile widget you can use for many purposes
besides just displaying text. This chapter covers the different
things you can put inside a Text widget (such as text, images, or
other widgets) and how to get the best use out of them. The derived
TextUndo and ROText (Read-Only Text) widgets are also discussed.
A Canvas widget can display objects such as circles, rectangles,
text, images, and even other widgets. This chapter covers all the
options and methods available, and shows how to use them.
The Scale widget is great for giving the user a range of numbers from
which to select so that users can't type in numbers out of
range or type in letters accidentally. This chapter includes examples
of the Scale widget and covers all the methods available for setting
it up and using it.
The Frame and Toplevel widgets are used to organize your other
widgets on the screen to get the look you want. This chapter shows
how you can use Frames and Toplevels in coordination with a geometry
manager (covered in Chapter 2, "Geometry Management") to make your
windows look the way you want them to. We also look closely at the
MainWindow, which is a specialized Toplevel in disguise.
Once an application gets complex enough, you will need to put a Menu
in it. This chapter shows different ways to create menubars and
pulldown, popup, tearoff, and option menus, and how they can best be
used in an application. We also cover menu virtual events and briefly
examine pie menus.
There are many methods available for all widgets in Perl/Tk. We cover
them in this chapter and show you how to use them. The two most
important of these methods are configure and
cget.
Creating custom widgets is sometimes the only answer to a problem.
This chapter covers all the details, including the Tk class
hierarchy, and gives you several examples of composite and derived
mega widgets to examine. You will find details here that appear
nowhere else in the known universe. Featured widgets are Tk::Nil,
Tk::CanvasPlot, Tk::LabOptionmenu, Tk::LCD, Tk::NavListbox,
Tk::Thermometer, Tk::CollapsableFrame, and Tk::MacCopy.
This chapter explores the inner workings of Tk's event loop,
including timers, I/O, mouse and keyboard events, bindings, and
callbacks. Featured modules are Proc::Killfam, Tie::Watch, Tk::Trace,
Tk::bindDump, and Tk::waitVariableX. Featured widgets are
Tk::ExecuteCommand, Tk::MacProgressBar, and Tk::Splashscreen.
This chapter covers the various image types and how to use them. We
examine Bitmaps, Pixmaps, Photos, and compound images, and touch on
tile, transparency, and animation issues. Featured widgets are
Tk::Animation, Tk::PhotoRotateSimple, Tk::Thumbnail, and
Tk::WinPhoto.
Tk provides an unusual IPC mechanism that allows Tk programs to send
messages amongst themselves. This chapter describes Perl-Perl,
Tcl-Tcl, and Perl-Tcl intercommunications, and discusses security
considerations. We compute with multiple processes and develop
a Perl plug-in for tclrobots so that Perl and
Tcl Robot Control Programs can do battle. Featured modules include
Tk::Receive and Tk::TclRobots.
LWP is a Perl library for accessing the World Wide Web. This chapter
develops a web client, tkcomics, that displays
our favorite comic strips. It details various nonblocking mechanisms
for both Unix and Win32. Featured modules are LWP::Simple,
LWP::UserAgent, and Tie::Win32MemMap. We then describe the PerlPlus
Netscape plugin, which allows you to embed Perl in Netscape and run
client-side programs.
This chapter is a grab-bag of miscellaneous information and simple
widgets such as Adjuster, Balloon, BrowseEntry, ColorEditor, Dialog,
DialogBox, ErrorDialog, LabFrame, NoteBook, Pane, ProgressBar,
chooseColor, getOpenFile, getSaveFile, and messageBox.
The Tk module doesn't come with the standard Perl distribution.
This appendix tells you where to download the latest release and
updates, and how to install them.