Errata

Learning Perl/Tk

Errata for Learning Perl/Tk

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 5
2nd paragraph

The paragraph implies that Perl/Tk is available from ActiveState. However, the
latest version (and all prior versions) of ActivePerl do not include
Perl/Tk--so trying to obtain it from ActiveState (as I did) is a fruitless and
frustrating experience. Note that although ActiveState provides the
*documentation* for the Tk module, it does not provide the Tk module itself--a
very strange state of affairs.

It is then stated that one may obtain Perl/Tk for Win32 on CPAN. This is an
illusion. First, the readme for the Perl/Tk tar file states that one must own
Visual C++ to create the module--an odd requirement for "free" software. But
even if one uses MicroSoft's freely available "nmake" utility, the "makefile"
built by the Tk installation script has fatal errors in it, according to
"nmake", and no build is done.

If there is a way to install Perl/Tk for win32, the book gives no guidance.

Anonymous   
Printed Page 5
2nd paragraph

This is actually in reference to the error stated by another reader in
regards to acquiring Tk for Windows. I use Windows, and have installed
ActivePerl on my machine with Tk. If you get the latest version (I don't
know about earlier models), you can use the ppm feature to install Tk with
minimum fuss. It is not just something for the Unix users. Although at the
time of writing it may not have been reasonable to get Tk for Windows, it is
not too difficult now.

Anonymous   
Printed Page 24
Bottom of page

this order: right, left, top, bottom" instead of "left, right..."

Anonymous   
Printed Page 27
(the code at the bottom of the page)

-anchor -> 'n'

should be

-anchor => 'n'

Anonymous   
Printed Page 29

Now reads:

"which widget should be placed *after* your new widget"

It's in the wrong order; the new widget is the one that is placed after the
other widget.

Anonymous   
Printed Page 29
caption to figure 2-21:

"$widget1" instead of "$done1".

Anonymous   
Printed Page 33
code for the "enlarge" button

To get this code snippet to work correctly, $mw can't be defined as "my
$mw", just as "$mw":

$mw = MainWindow->new;

This should either be noted on pg 33 or defined that way in the earlier
versions on pages 17 & 18.

If you haven't seen this before, possibly I am using a version of Tk/perl
which checks for errors which the version used to write the book missed.

[ccurley@charlesc tkperl]$ rpm -qa | grep -i perl
perl-5.6.0-12
groff-perl-1.16.1-7
perl-SGMLSpm-1.03ii-4
postgresql-perl-7.0.3-8

[root@charlesc /root]# find .cpan/ -iname tk* | grep -i gz
.cpan/sources/authors/id/N/NI/NI-S/Tk800.023.tar.gz

The error message I see is:
[ccurley@charlesc tkperl]$ ./enlarge.pl
Tk::Error: Can't call method "packSlaves" on an undefined value at
./enlarge.pl line 8.
[&main::repack_kids]
Tk callback for .button1
Tk::__ANON__ at /usr/lib/perl5/site_perl/5.6.0/i386-linux/Tk.pm line 228
Tk::Button::butUp at
/usr/lib/perl5/site_perl/5.6.0/i386-linux/Tk/Button.pm line 111
(command bound to event)

Anonymous   
Printed Page 40
second code fragment, 3rd line

There is a comma missing from the end of the line; it should read:

("-", $mw->Button(-text=>"Button 6", -command=>sub {Exit}), "-",

Anonymous   
Printed Page 41
In the last paragraph:

1.) The sentence "Notice in Figure 2-31 how Buttons 5 through 8 are also wider
than they really need to be" actually doesn't match Figure 2-31.

2.) Next sentence ("This is because ...") seems to be not sufficient as an
explanation, since the metioned option is used for *both* rows (see following
code). This could confuse some readers.

Anonymous   
Printed Page 62
footnote

Description of mouse button numbering assumes right-handed user. Now, I'm
right-handed, but use my mouse left-handed because it distributes carpal
tunnel abuse between my wrists better, and because I can then use mouse and
keypad simultaneously. In any case, maybe "mouse button 1 is under the index
finger...", etc., or something more scientifically general.

Anonymous   
Printed Page 65
first code fragment

There is an incorrect use of the configure method. The line should read:

-command=>sub {my $state = $exit_b->cget(-state);

Anonymous   
Printed Page 66
In the footnote, the 2nd sentence ("I have no idea why ..."):

Version numbers 5, 6, and 7 had been skipped to adapt the versions numbers of
Tcl to those of Tk. Before, for example, Tk 4.2 belonged to Tcl 7.4, which was
confusing.

Anonymous   
Printed Page 67
Middle of page

"(see Chapter 2)" inst. of "(see Chapter 1)"

Anonymous   
Printed Page 70

The fifth paragraph now reads "character sizes." Shouldn't that read :

"number of characters" or the like?

Anonymous   
Printed Page 74
Not sure, but isn't 'ececec' for -activebackground *lighter* than the

value for -background?

Anonymous   
Printed Page 76
program listing to display cursors

When using this program under Windoze the correct directory is

C:PerlsitelibTkX11cursorfont.h

Anonymous   
Printed Page 77
code

When running the code using the code printed on this page, I receive an error
referring to the Tk.pm file. Actually, in the book, at page 142, the same code
line is printed, which appears to be correct, although I haven't rerun the
program with the changes, yet.

Anonymous   
Printed Page 79
sentence just above the figure 3-23:


"the right button is the one that has the focus"

should be

"the left button..."

Anonymous   
Printed Page 84
"-highlightthickness" description:

Replace "window" with "widget".

Anonymous   
Printed Page 85
-variable:

"$variable" (in description line) should read "$value" (see synopsis line
above and the following section).

Anonymous   
Printed Page 86
In Figure 4-2, the order of "CB on" and "CB off" has to be changed in

either the code or the figure.

Anonymous   
Printed Page 89
The meaning of the "Be careful ..." paragraph is pretty hard to figure

out because "$variable" is not explained.

Anonymous   
Printed Page 95
Bottom of page

"configure" is a method, not a command (in "configure command").

Anonymous   
Printed Page 96
Line 4

Now reads:

"You'll only see this small strip..."

Should read:

"You'll see only this small strip..."

This is an example of an error that occurs often in the book (and in many
other books these days). The word "only" is misplaced so it modifies the
incorrect word. There are many other examples of this type of error in the
book.

Anonymous   
Printed Page 104
In the description of -relief, "button" should read "label".

Anonymous   
Printed Page 106,107
The code does not use "-relief groove".

Anonymous   
Printed Page 115
Figure 5-6 caption

The value used is 10, not 5.

Anonymous   
Printed Page 117
2nd paragraph after Figure 5-10

The author states that $entry->configure(-show=>""); will not clear a shadowed
entry. While technically correct, this is grossly misleading, because
$entry->configure(-show=>undef); DOES clear the shadowed entry.

Anonymous   
Printed Page 122 & 123
Can someone check Figure 5-13 and the according text on page 122

(para -4). There seems to be some confusion. I assume the following
corrections:

In text: change "50%" to "20%" (in "50% of the text is actually visible").
Reason: 50% - 30% = 20%

In figure: move the left margin of the grey field to the right so that there
are actually 30% of the text is to the left of the grey field (the widget) and
that 20% of the text is in the grey field.

Anonymous   
Printed Page 146
2nd line

The "solid" relief type is not in the list "flat, raised, groove..."

Anonymous   
Printed Page 147
box, line 1:


"in an entry widget"

should be

"in a listbox widget"

Anonymous   
Printed Page 147
In the last paragraph, "(see "Listbox Indexes" later in this chapter)":

"later" should be deleted, since this section doesn't come later in the
chapter but some paras before (top of same page).

Anonymous   
Printed Page 156
difference b/w "-insertwidth" and "-insertborderwidth" unclear

Anonymous   
Printed Page 161
Code, sub save_file

The sub doesn't close the file, destroying it unless you change the filename, which merely destroys the new filename (!).

Add -

close FH;
after the print statement.

Eleven years down the line, and no-one noticed? This book has been an education; it is so bug-ridden that it _really_ keeps the reader on their toes.

Pete Morris  Jan 07, 2010 
Printed Page 165
"-offset": expressed in pixels

"-relief": "solid" is not in the list

Anonymous   
Printed Page 166
This code works (beware, Fr version)

=-=-=-=-=-
$texte = $mw->Text()->pack();
$texte->tagConfigure('gras', -font =>
"-*-Courier-Bold-B-Normal--*-120-*-*-*-*-*-*");
# Utilisez -font => "{Courier New} 24 {bold}" pour les syst?mes Win32
$texte->insert('end', "Voici du texte normal
");
$texte->insert('end', "Voici du texte en gras
", 'gras');
-=-=-=-=-=

Anonymous   
Printed Page 167
(bottom) this code works

=-=-=-=-=-
@liste_de_listes = $texte->tagConfigure("bleu");
foreach $opt (@liste_de_listes) { print "@$opt
"; } # l'affiche
-=-=-=-=-=

Anonymous   
Printed Page 168
missing ";" after the second line of code

Anonymous   
Printed Page 169
"psuedo" should be "pseudo".

Anonymous   
Printed Page 170
last complete paragraph

The explanation is not provided w/ respect to the example.

Anonymous   
Printed Page 171
1st line of code in "Determining where a tag applies"

missing ";" at the end

Anonymous   
Printed Page 173
top of page

missing ">" in "values for op are":

"returns a 1 because ...": use "less" instead of "less than".

Anonymous   
Printed Page 174
1st line of code

Use "dlineinfo" instead of "lineinfo".

Anonymous   
Printed Page 175
"getNames" should (probably) read "markNames".

Anonymous   
Printed Page 180
very last chapter characters

should be "." instead of ".,"

Anonymous   
Printed Page 181
code

"values" should read "value".

Anonymous   
Printed Page 184
Third Code Block and Footnote

The fist line of the Third code block should read:
$c = $mw->Scrolled("Canvas")->pack();
(That's a capital C on Canvas)

The Footnote should read CanvasBind (Captials on both the C and the B - not
just the B as it is printed) in both occurrences in the footnote.

(This is from my experiences using Tk8.0 and trying the example code)

Anonymous   
Printed Page 198
last line of code

"Button!" should be "Button!
".

Anonymous   
Printed Page 202
1st paragraph

The example for $canvas->bbox reads

($l, $r, $t, $b) = $canvas->bbox("blue", "red");

Even though there was no mentioning what $l, $r, $t, and $b are, I assumed
they meant left, right, top and bottom, respectively. With this assumption,
the correct order returned by $canvas->bbox is

($l, $t, $r, $b) = $canvas->bbox("blue", "red");

Anonymous   
Printed Page 204
2nd paragraph, line 3

"of the tabs" should be "of the tags."

Anonymous   
Printed Page 205
last option (-y), Copy&Paste error from para above:

"Default is left edge" should read "Default is top edge."

Anonymous   
Printed Page 211 and 215
option -bigincrement:

"1/10 the top value of the scale" or "1/10 the total range"?

Anonymous   
Printed Page 223

The description of "-menu" is not adequate.

we used:
=-=-=-=-=-
Indique au bouton de menu qu'il doit afficher le menu associe' a`
$menu, et donc ne'gliger l'option -menuitems.
-=-=-=-=-=
approx meaning:
=-=-=-=-=-
The menubutton will display the menu contained by $menu (neglecting
-menuitems)
-=-=-=-=-=

Anonymous   
Printed Page 224
for -underline

-takefocus must be <> 0.

Anonymous   
Printed Page 227
AddItems example does not work.

Correct syntax:
$Menub->AddItems(["command"=>"Item1",-command=>[&DoItem,"Param1"]]);

Anonymous   
Printed Page 235
4th paragraph, Adding a Cascade Menu

Could not really tell if your information here was correct or not. It would
not work for me, though it is new to me. I suspect it is incorrect though. I
found a very useful example in the Perl Cookbook that is very easy to
understand, it creates a Cascade menu like so.

"excerpt"
Here's how to use menuitems to make an Edit menu:

my $f = $menubar->Menubutton(-text => "Edit", -underline => 0,
-menuitems =>
[
[Button => 'Copy', -command => &edit_copy ],
[Button => 'Cut', -command => &edit_cut ],
[Button => 'Paste', -command => &edit_paste ],
[Button => 'Delete', -command => &edit_delete ],
[Separator => ''],
[Cascade => 'Object ...', -tearoff => 0,
-menuitems => [
[ Button => "Circle", -command => &edit_circle ],
[ Button => "Square", -command => &edit_square ],
[ Button => "Point", -command => &edit_point ] ] ],
])->grid(-row => 0, -column => 0, -sticky => 'w');

In closing I would recommend more detailed example, thanks.

Anonymous   
Printed Page 243
in the "entreyconfigure" code:

The comma must be inside the braces.

Anonymous   
Printed Page 244
code comment:

"intially" should be "initially".

Anonymous   
Printed Page 244
4th paragraph, last line

"(discussed later in this chapter)" should be "earlier".

Anonymous   
Printed Page 248
last line

The option in this code sample should also be called with a reference.

Thus:

-textvariable => $number

should read

-textvariable => $number

Anonymous   
Printed Page 254
-5.2 (reported by Achim Bohnet, who was reviewer for both the original

and translation):

"compilation error" should be "run time error". (This error looks like a
compilation error but actually isn't one.)

Anonymous   
Printed Page 256
end of 2nd paragraph

"indentifier;" should be "indentifier:".

Anonymous   
Printed Page 256
2.1 Achim Bohnet suggests:

"(besides frame)" should be "than Frame". (Frame starts with a capital letter
here because it is a class name in this case.)

Anonymous   
Printed Page 257
1.4-6 (Achim Bohnet)

Toplevel widgets display automatically. Therefore the explanation why
MainWindow is special is not correct.

Special is instead:
- closing of (the last) MainWindow finishs/stops (?) event processing of Tk
- MainWindow does not have a ParentWidget

Anonymous   
Printed Page 261
Maximum size

$toplevel->maxsize(300, 300);

Suggestion: using different values for the parameters same for minsize (below)

Anonymous   
Printed Page 262
Using a Size Aspect

The Fr translator thinks that the description is somewhat insufficient (the
official documentation is more precise).

(262/263) Order of deiconify, iconify and withdraw should be changed so that
deiconify is explained *after* iconify and withdraw (move the section to right
before the "Specifying the Icon Bitmap" header).

Anonymous   
Printed Page 265
Assigning an Application Name (Achim Bohnet)

The description of client() suits to appname() but not to client(). (See
Widget.pod, option.pod for appname() and Wm.pod for client()).

Anonymous   
Printed Page 268
"Being the Leader":

This section needs information on what a "group leader" is used for. (Without
that, the reader has no use for the section).

Anonymous   
Printed Page 269
Last paragraph

"from the last chapter" is chapter 11, in fact.

Anonymous   
Printed Page 270
In the first paragraph:

"generated by the program" should read "generated by the user."

Anonymous   
Printed Page 272
middle

("<Button-3>")

The parentheses seem useless.

Anonymous   
Printed Page 272
bottom

"sequence" should read "callback".

Anonymous   
Printed Page 277
4th paragraph, last sentence

The quotes are misplaced (comma inclusion) in "dollar," "percent," ...

Anonymous   
Printed Page 284
2nd paragraph

Suppress "five lines".

Anonymous   
Printed Page 285
6th paragraph

"subwidget" should read "Subwidget" (same on page 286).

Anonymous   
Printed Page 289

The last line is unclear. What is "ConfigDefaults"? Should it read :

"ConfigSpecs"?

Anonymous   
Printed Page 293
in the first snippet

"color" may in fact be "SlateGrey".

Anonymous   
Printed Page 295
"Exists" is not a method; it is a function.

Anonymous   
Printed Page 295
snippet in "is the widget mapped":

The "{" of the "if" form is missing.

Anonymous   
Printed Page 295
1st para, line 3:

With appname you change the name of the application, not the name of the file.

Anonymous   
Printed Page 297
There is no real explanation of the Perl/TK methods "update" and

"idletasks" in Learning Perl/TK. These methods allow you to update widgets
"asynchronously". This is very important if you need change a mouse cursor,
accept user input, or refresh displays before a long-running subroutine
returns.

Very vague reference is made to "update" on this page. It is useless. No
mention is made of "idletasks".

Anonymous   
Printed Page 299
bottom, last snippet

"()" missing after "visualsavailable"

Anonymous   
Printed Page 301
"The -selection method" is not a method but an option.

Anonymous   
Printed Page 303
9th paragraph

The text states:

To find out the order in which the focus will change,
you can use the focusNext and focusPrev methods.

This appears to be incorrect. focusNext and focusPrev _change_ the focus, but
do not tell you where it will change to.

There does not appear to be a method of telling what the next (or previous)
focus widget will be without changing focus.

Anonymous   
Printed Page 305
"OnDestory" should be "OnDestroy".

Anonymous   
Printed Page 306
In para 4, line 2:

", especially a graphical program" should be deleted.

Anonymous   
Printed Page 306
6th paragraph

"methods" (inside Getopts) should be "functions".

Anonymous   
Printed Page 306
code

The code

$widget->after(1000, &do_something);

causes memory leaks on Win32 systems.

The simple program is causing a memory leak in Tk800.022. There was no memory
leak with 800.015. I suspect that this problem exists in Tk800.020 also, but
unfortunately I don't have 020 any longer.

The bug seems to be in creating callback object from raw ref-to-sub. If you
code as :

sub timerTest {
$test++;
$m->update();
$m->after(1, [&timerTest]);
}

i.e. provide needed anon array yourself it does not leak. Should be easy
enough to fix the other case now I have localized the problem.

This is all down to the fact that I need to "bless" something into an object
(so it can have a DESTROY so I can cleanup) and blessing the sub itself caused
other problems. So given:

$m->after(1, &timerTest);

I do bless [&timerTest],"Tk::Callback"; but seems I get reference count off
by one so it never gets destroyed. However if you pass in the anon array I
just bless that and there are no ref count issues.

Now the question is only what was significant change between .015 and .022
which caused the leak - given that .022 is supposed to fix lots of leaks...

Anonymous   
Printed Page 310
This code works

=-=-=-=-=-
use Tk;
use Tk::Pretty;

$mw = MainWindow->new();
$widget = $mw->Button;
@config = $widget->configure();
print Pretty @config;
-=-=-=-=-=

Anonymous   
Printed Page 313-330
I suggest that the table of default values associated with widgets

is unnecessary and could easily be eliminated.

Anonymous   
Printed Page 332
In the paragraph below "WIndows NT and 95":

Replace "application" with "window" in:

"a small bar that will iconify the application"

and

"In the upper-left of the application."

Anonymous   
Printed Page 334
in "Times 12 Normal:"

The best place for the dot is outside the quotes.

Anonymous   
Printed Page 337
Line -1 before "Font Methods:"

"Tk::Font" should be "Tk::Fonts".

(Chapter 6) In the scroll_listboxes subroutine, it should read:

$list->yview(moveto=>$top); # Adjusts each listbox

INDEX:
MainLoop is not a method (but a function). Same with CmdLine.

?Reader suggestion? I would like to suggest that in a future edition, Ms.
Walsh include coverage of the Tix widgets. At the very least, coverage of the
more popular composite widgets like FileSelect would be welcome. The
documentation that comes with these widgets tends to be spotty.

Anonymous