wxPython in Action: Errata

Front Matter

Chapter 1

pg. 4: The first line in listing 1.1 should be "#!/usr/bin/env python"

pg. 13: The docstring at the beginning of listing 1.2 should match that shown in the code snippet at the bottom of the page.

pg. 15: Add the following to the end of the first paragraph in section 1.4:  "This sample uses an image file named wxPython.jpg, which can be found in the downloadable source code package for this book.  Just copy it to the same place where your hello.py file is located."

pg. 15: In listing 1.3 add "self.SetClientSize(size)" to the end of Frame.__init__

Chapter 2

pg 44: wx.Point doesn't have a > operator but it does have == and !=, so replace the last line of the code snippet at the top of the page with "same = (x == y)" 

pg. 45: Replace the paragraph about using XOR with this: 


To remove individual style bits from a composed style, you use the bitwise and operator, & with the bitwise complement operator, ~. For example, to create a window that is based on the default, but which is not resizable by the user, you could do this:



pg. 48: Change "listing 2.5" in the last paragraph to "listing 2.3"

pg. 49: Change two instances of "Chapter 7" to "Chapter 6"

pg. 49, listing 2.4: The sample does an import of the images module, but this module is not shown in the book because it is mostly just the binary data of image files encoded as python code.  The module is available as part of the downloadable source package.  Add text to this effect to the paragraph introducing listing 2.4.

pg. 53: The fourth line of the code snippet for the wx.SingleChoiceDialog should end in a closing parenthesis instead of a comma.

Chapter 3

pg 58, bottom of the page: Replace "users" with "user's"

pg. 69: Replace "hirerarchy" with "hierarchy"

Chapter 4

pg. 107, last paragraph: Change reference to "listing 4.1" to "listing 4.3"

Chapter 5

pg. 137: Replace "have to flexible."  with  "have to be flexible."

Chapter 6

pg. 150, Listing 6.1:  Due to a limitation on the Mac bitmaps are not allowed to have a size with a dimension of zero, so we need to protect against that possibility when creating the buffer bitmap.  To do this, change the second line in the InitBuffer method to be like this:

  self.buffer = wx.EmptyBitmap(max(1, size.width), max(1, size.height))

pg. 157: Change 2 instances of "SetStatusWidth" to "SetStatusWidths"

pg. 163: Remove the "newId = wx.NewId()" line from the createColorTool method in the code listing

pg. 166: The last entry in table 6.6 should refer to table 6.7 insted of 6.6.

pg. 176, listing 6.9: Change the 2nd line in the OnSetColor method to this:

    if color != self.sketch.color and self.sketch.color in self.colorButtons:

pg. 180, Listing 6.11:  The code in the book is valid, however the name of the image file does not match what is in the downloadable sample code.  Change ".bmp" to ".png" and remove the wx.BITMAP_TYPE_BMP parameter.

Chapter 7

pg. 195:  Remove the 2 sentences at the end of the 2nd paragraph: "The class does not have setter methods, since instances of wx.TextAttr are immutable. To change the style of text, you must create an instance."

pg. 222:  Replace "called on a combo box, as displayed in table 7.14."  with "called on a combo box, as displayed in table 7.14, except for Set(choices) which is specific to wx.ListBox."

Chapter 8

pg 245: Replace  "i.e.,"  with "e.g.,"

Chapter 9

pg. 265: Replace "the user entered string" with "the user-entered string"

pg. 266: The clientData parameter of wxSingleChoiceDialog is not supported in wxPython, so remove the "clientData=None, " in the code snippet at the bottom of the page.

pg. 267-268, listing 9.5:  The code listing demonstrating the wx.ProgressDialog doesn't run well stanalone because of the lack of a MainLoop to dispatch events.  It should be replaced with this sample:

import wx

class Frame(wx.Frame):

    def __init__(self, parent):

        wx.Frame.__init__(self, parent, title="ProgressDialog sample")

        self.progressMax = 100

        self.count = 0

        self.dialog = None

        self.timer = wx.Timer(self)

        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)


    def OnTimer(self, evt):

        if not self.dialog:

            self.dialog = wx.ProgressDialog("A progress box", "Time remaining",



                                            | wx.PD_ELAPSED_TIME

                                            | wx.PD_REMAINING_TIME)

        self.count += 1

        if wx.VERSION < (2,7,1,1):

            keepGoing = self.dialog.Update(self.count)


            (keepGoing, skip) = self.dialog.Update(self.count)

        if not keepGoing or self.count == self.progressMax:




if __name__ == "__main__":

    app = wx.PySimpleApp()

    frame = Frame(None)




pg. 281:  In the code snippet at the top of the page replace "wx.WizardPage" with "wx.wizard.WizardPage"

pg. 281:  Insert the following as the second sentence in the last paragraph of section 9.3:  "Since the intended use of the wx.wizard.WizardPage class is to derive a custom class from it and override specific methods, wxPython, as in other examples that we've seen, provides a wx.wizard.PyWizardPage class that knows how to reflect virtual method calls to the Python methods in the derived class."

Chapter 10

pg. 295: In the second code snippet at the top of the page the second line should read "self.SetMenuBar(menubar)"

Chapter 11

pg. 333: wx.ALIGN_RIGHT is missing from the table.

pg. 338: Change 'the cells for "two" and "seven" are wider' --> 'the cells for "two" and "eight" are wider'

pg. 340: Replace "sizer.AddGrowableRow(1, 5)" with "sizer.AddGrowableRow(1, 2)"

Chapter 12

pg. 363: In the last entry in the table replace "orginal" with "original"

pg. 363: Replace "SetMaskColor" with "SetMaskColour" in the paragraph at the bottom of the page.

pg. 370: In the last paragraph replace "wx.BufferedPaintDC(dc, buffer=None)" with "wx.BufferedPaintDC(window, buffer=None)"

Chapter 13

Pg. 400:  Replace "Images larger than the specified size are not allowed."  with "There are some slight platform differences with respect to images that are not the specified size, so the safest thing to do is to ensure that your images are the same size as specified."

Pg 416: Replace two instances of SetListData with SetItemData

Chapter 14

pg 428: Change "wx.grid.Grid.SelectionColumns" to "wx.grid.Grid.SelectColumns" 

pg 430: Remove the "not" from the test in IsEmptyCell.

pg 432: Change "other than the end of your grid" to "other than at the end of your grid"

pg 436: Change "SetColumnLabelAlignment" to "SetColLabelAlignment"

pg 436: Change "GetLabelTextFont" to "GetLabelTextColour"

pg 438: Change "change the width of a row." to "change the height of a row."

pg 439: Change "which sets the width of the column labels" to "which sets the height of the column labels"

pg 444: Change "wx.LEFT" --> "wx.ALIGN_LEFT", "wx.CENTRE" --> "wx.ALIGN_CENTRE", "wx.RIGHT" --> "wx.ALIGN_RIGHT", "wx.TOP" --> "wx.ALIGN_TOP, "wx.CENTRE" --> "wx.ALIGN_CENTRE", "wx.BOTTOM" --> "wx.ALIGN_BOTTOM"

pg 445: Change "SetColAttr(attr)" --> "SetColAttr(col, attr)", "SetRowAttr(attr)" --> "SetRowAttr(row, attr)", "SetGridLineColor(colour)" --> "SetGridLineColour(colour)"

Chapter 15

pg. 472: In the code snippet at the top of the page "getNextChild" should be "GetNextChild"

Chapter 16

pg 502: in the code snippet at the bottom of the page, remove the "self," parameter.

Chapter 17

Chapter 18

pg 531: In the code snippet in the middle of the page replace "MyDataTarget" --> "MyDropTarget"

pg 532: In the 3rd paragraph "when the target invoked." --> "when the target is invoked."


Sample Source Code

In Chapter-02/startup.py, remove line line 22, the print "app name:"... line