Learning Perl/Tk by Nancy Walsh Unconfirmed error reports are from readers. They have not yet been approved or disproved by the author or editor and represent solely the opinion of the reader. This page was updated July 10, 2002 Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification UNCONFIRMED errors and comments from readers: General comment: "X Windows" should read "X Window." [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. [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. {24} Bottom of page: this order: right, left, top, bottom" instead of "left, right..." {27} (the code at the bottom of the page): -anchor -> 'n' should be -anchor => 'n' (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. {29} caption to figure 2-21: "$widget1" instead of "$done1". {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) (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}), "-", (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. (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. {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); (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. (67) Middle of page: "(see Chapter 2)" inst. of "(see Chapter 1)" (70) The fifth paragraph now reads "character sizes." Shouldn't that read "number of characters" or the like? (74) Not sure, but isn't 'ececec' for -activebackground *lighter* than the value for -background? {76} program listing to display cursors: When using this program under Windoze the correct directory is C:\Perl\site\lib\Tk\X11\cursorfont.h [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. {79} sentence just above the figure 3-23: "the right button is the one that has the focus" should be "the left button..." {84} "-highlightthickness" description: Replace "window" with "widget". {85} -variable: "$variable" (in description line) should read "$value" (see synopsis line above and the following section). (86) In Figure 4-2, the order of "CB on" and "CB off" has to be changed in either the code or the figure. (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. {89} The meaning of the "Be careful ..." paragraph is pretty hard to figure out because "$variable" is not explained. {95} Bottom of page: "configure" is a method, not a command (in "configure command"). (104) In the description of -relief, "button" should read "label". {106,107} The code does not use "-relief groove". {115} Figure 5-6 caption: The value used is 10, not 5. [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. (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. {146} 2nd line: The "solid" relief type is not in the list "flat, raised, groove..." (147) box, line 1: "in an entry widget" should be "in a listbox widget" (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). (156) difference b/w "-insertwidth" and "-insertborderwidth" unclear {165} "-offset": expressed in pixels "-relief": "solid" is not in the list {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\n"); $texte->insert('end', "Voici du texte en gras\n", 'gras'); -=-=-=-=-= {167} (bottom) this code works: =-=-=-=-=- @liste_de_listes = $texte->tagConfigure("bleu"); foreach $opt (@liste_de_listes) { print "@$opt\n"; } # l'affiche -=-=-=-=-= {168} missing ";" after the second line of code (169) "psuedo" should be "pseudo". (170) last complete paragraph: The explanation is not provided w/ respect to the example. {171} 1st line of code in "Determining where a tag applies": missing ";" at the end {173} top of page: missing ">" in "values for op are": "returns a 1 because ...": use "less" instead of "less than". {174} 1st line of code: Use "dlineinfo" instead of "lineinfo". {175} "getNames" should (probably) read "markNames". (180) very last chapter characters: should be "." instead of ".," {181} code: "values" should read "value". {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) {198} last line of code: "Button!\" should be "Button!\n". {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"); (204) 2nd paragraph, line 3: "of the tabs" should be "of the tags." (205) last option (-y), Copy&Paste error from para above: "Default is left edge" should read "Default is top edge." {211 and 215} option -bigincrement: "1/10 the top value of the scale" or "1/10 the total range"? {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) -=-=-=-=-= {224} for -underline: -takefocus must be <> 0. {227} AddItems example does not work. Correct syntax: $Menub->AddItems(["command"=>"Item1",-command=>[\&DoItem,"Param1"]]); [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. {243} in the "entreyconfigure" code: The comma must be inside the braces. (244) code comment: "intially" should be "initially". (244) 4th paragraph, last line: "(discussed later in this chapter)" should be "earlier". {248} last line: The option in this code sample should also be called with a reference. Thus: -textvariable => $number should read -textvariable => \$number (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.) {256} end of 2nd paragraph: "indentifier;" should be "indentifier:". (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.) {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 {261} Maximum size: $toplevel->maxsize(300, 300); Suggestion: using different values for the parameters same for minsize (below) {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). (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()). (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). {269} Last paragraph: "from the last chapter" is chapter 11, in fact. (270) In the first paragraph: "generated by the program" should read "generated by the user." {272} middle: ("") The parentheses seem useless. {272} bottom: "sequence" should read "callback". (277) 4th paragraph, last sentence: The quotes are misplaced (comma inclusion) in "dollar," "percent," ... (284) 2nd paragraph: Suppress "five lines". {285} 6th paragraph: "subwidget" should read "Subwidget" (same on page 286). (289) The last line is unclear. What is "ConfigDefaults"? Should it read "ConfigSpecs"? {293} in the first snippet: "color" may in fact be "SlateGrey". {295} "Exists" is not a method; it is a function. {295} snippet in "is the widget mapped": The "{" of the "if" form is missing. (295) 1st para, line 3: With appname you change the name of the application, not the name of the file. {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". {299} bottom, last snippet: "()" missing after "visualsavailable" {301} "The -selection method" is not a method but an option. [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. {305} "OnDestory" should be "OnDestroy". (306) In para 4, line 2: ", especially a graphical program" should be deleted. {306} 6th paragraph: "methods" (inside Getopts) should be "functions". (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... {310} This code works: =-=-=-=-=- use Tk; use Tk::Pretty; $mw = MainWindow->new(); $widget = $mw->Button; @config = $widget->configure(); print Pretty @config; -=-=-=-=-= (313-330) I suggest that the table of default values associated with widgets is unnecessary and could easily be eliminated. (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." (334) in "Times 12 Normal:" The best place for the dot is outside the quotes. {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.