Learning Perl/Tk by Nancy Walsh If you have any error reports or technical questions, you can send them to booktech@oreilly.com. (Please specify the printing date of your copy.) This page was updated on March 12, 2001. 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 Confirmed errors: (1, 5) Tk does not in fact come with the latest ActiveState Perl unless one knows that one should install Perl and then go on-line and issue PPM and INSTALL TK. You must use the ppm module manager to install the Tk module (and do special things if there is a firewall). Change the text on this page to make it fit without breaking the current page breaks? {140} now reads: $list->yviewMoveto($top); should read: $list->yview('moveto',$top); {152} in the Listbox example, the code: # This routine is called each time we push a keyboard key sub do_search { my ($entry, $key) = @_; Add right after MainLoop; as the comment to the sub do_search comment (first line repeated for clarity): # This routine is called eat time we push a keyboard key # Note that the 2nd arg, $key, is the specific key char # the user pressed, and not the entire $search string. (156) In the description of -insertborderwidth option, change Changes the width of the insert cursor. to Changes the width of the insert cursor's borders. (157) Description of -tabs option, change text in parens from: (or not tab stops) to (or use the default tab stops, which is ever 8 chars) (162) In the second sentence under chars/lines modifier, change "end - 1 chars" to "end - 1 lines". (168) The first sentence of the page, change from: Each list within the list contains two elements: the option name and the value. to: Each list within the list contains five elements: two of which are the option name and value. Change code snippet to read: @list = $text->tagConfigure("blue", -font); (168) 4th paragraph in section "Adding a Tag to Existing Text," change If both tags try to alter the same option (such as -font), the last setting for that option wins. to If both tags try to alter the same option (such as -font), the last setting for that option wins, unless the tag's priority was changed using tagRaise or tagLower. *** put tagRaise and tagLower in courier font. (170) 1st sentence in section "Raising and Lowering Tags," change When there are several tags applied to the same text, the last tag added to the text overrides the previous ones, and its.... to When there are several tags applied to the same text, the configuration options of the last tag added are given priority. (173) In the last line, change last bullet from: Baseline position of the line, measured from x to Baseline position, measured from the X coord returned as first element (175) In the second paragraph in section "Marks", change sentence from: If the gravity is 'left', the text will be inserted to the left of the mark and the mark will refer to the left of the last character inserted. to: If the gravity is 'left', the text will be inserted to the right, and the mark stays on the left of the last character inserted. When using 'left', the text seems to be inserted backwards. (175) in the 3rd paragraph in section "Marks," change text from (as long as the mouse button is pressed). to (as long as the mouse button is not pressed). (188) in code fragment under -extent option: # This will draw _ of an oval should be # This will draw 3/4 of an oval (190) in paragraph before the -anchor option, change: The other captions available for createBitmap are: to The options available for createBitmap are: (196) Change sentence under Deleting Characters from: If the end index isn't specified, all the characters to the end of the string will be deleted (including any "\n" characters). to If the end index isn't specified, only the character at $first is deleted, leaving the rest of the string intact. **Make sure to put $first into courier font. (200) Under addtag "closest" change sentence from: This allows you to delete a subset of the tabs, to This allows you to delete a subset of the tags, (200) Under the description of "closest" keyword, change There are two more possible arguments for this form of addtag. You can specify a number that indicates how far out from the x,y coordinates items are to be considered. For instance, if you want an item that is within 10 pixels to be considered "closest", make the call as follows: to If more than one item overlaps the specified point then the last item added in the stack will be returned. To add to the area considered a part of the overlap, you specify an additional number that will essentially enlarge the overlap area. To add 10 pixels to the overlap area: (200) Under the description of "enclosed" keyword, change the last part of paragraph from: x1 < x2 and y1 < y2 to x1 <= x2 and y1 <= y2 (201) In section "Binding Items Using Tags," remove all Tk:: portions in front of Tk:: bind in code examples only. Do not change the text. (205) Under the -y option, change: Default is the left edge of the window. to Default is the top edge of the window. (211) Under the description of -bigincrement option, change ... causing the value to change by 1/10 the top value of the scale. to: ... causing the value to change by 1/10 the total range of the scale. (213) Change 3rd sentence from: If you happen to switch them, the scale will still display with the higher value on the right and the lower value on the left. to If you happen to switch them, the scale will simply display the -from value on the left and the -to value on the right. ***Make sure and put -from and -to in courier font. (224) Under -textvariable option, change The information displayed in $variable should be... to The information contained in $variable should be... (224) Delete the following sentence (I think it is a version thing): Torn-off menus won't be be updated when other events in the program are updated, so it is a good idea to limit your use of tear-off menus. (227) In section "Radiobutton item type," change in last paragraph: -variable => $variable to -variable => \$variable **Make sure to keep courier font (230) In the second paragraph, change: We can use the menubutton widget's menu() method to return the actual menu item and then create the new menu as a child of the menu item. to: We can use the menubutton widget's menu() method to return the actual menu widget and then create the new menu as a child of that menu widget. (239) In the usage of -relief option, change from: -relief => 'flat' | .... | 'sunken' to -relief => 'flat' | .... | 'sunken' | 'solid' (240) In section "Menu Style," change from: -relief => 'flat' | .... | 'sunken' to -relief => 'flat' | .... | 'sunken' | 'solid' (240) In the middle of the page, change sentence from: Changing the -borderwidth... to Increasing the -borderwidth... (248) In the last sentence of section "Optionmenu Widget", change from: To add items, use the -options command instead of... to: To add items, use the -options option instead of... (249) In the first code example, the last two lines read: -textvariable => $displayed, -variable => $number Change to -textvariable => \$displayed, -variable => \$number (249) In the 2nd(3rd?) paragraph ("The -command option..") change: The default arguments to the callback are the variables assigned with -textvariable and then -variable (if it exists). to: The default arguments to the callback is the stored value for the menu, regardless of -textvariable and -variable option values. (252) Syntax of -colormap option, change sentence from: Default is undef. to Default is undef, which means to use the parent's colormap. (255) Near the bottom of the page, in paragraph about -visual option, change from: The number indicates the depth of color used (2 = black/white) to The number indicates the number of colors used (2 = black/white) (265) In section "Assigning an Application Name," change section title to "Setting the Client Machine Name" and the contents of that section should be replaced with this: You can set the property stored in WM_CLIENT_MACHINE by calling the client method with an argument: $toplevel->client("name"); To find out the current name sent: $name = $toplevel->client; If you send an empty string to client, then you'll erase any value previously stored in WM_CLIENT_MACHINE. (267) the second half of the paragraph at section "The Focus Model," change sentence from: The changes present in your application depend completely... to The way focus changes in your application depends completely... ^^^^^^^^^^ ^^^ (268) In section "Who Placed the Window?" change last sentence on page from: , the user manually placed the window when it was created. to: , the user requested the position of the window. (269) In section "Not a Real Window," change the text: (such as a pull-down menu) to: (such as a torn-off menu or a dialog) (272) 3rd paragraph under $widget->bind(tag ...), change the text from: If we didn't, we would get a list of.... to: If we didn't specify a callback, we would get a list of.... (274) Under Button# modifier, change from: , if you want to trigger an event when the user clicks on mouse button 1 and then mouse button 3, you can use... to , if you want to trigger an event when the user clicks on mouse button 3 while holding down mouse button 1, you can use... Also change: .. would not be triggered if you clicked mouse button 3 and then mouse button 1. to .. would not be triggered if you clicked mouse button 1 while holding down mouse buttom 3. (274) Under Double modifier, change: Double puts a constraint on the minimum amount of time... to Double puts a constraint on the maximum amount of time... (289) In the last sentence, change ConfigDefaults to ConfigSpecs **Make sure to leave the font as courier. (336) from the footnote, change the sentence: The curly braces are not required. to: The curly braces are not required unless there is a space in the font name. (355) index: Add the entry sticky, 37-38. (358) The last page of the index is missing (blank) from the March and May reprints. Please consult the online index at http://www.ora.com/catalog/lperltk/inx.html for entries width (continued) entry through yview method scrollbar