Chicago Cubs - a standalone model class

Hi chaps
Has anyone made listing 5.10 work in Robin Dunn "the software
craftsman"'s book wxPython in Action?

This example seems to be a more useful implementation than the
previous examples, and so I had a go at making it work. The key seems
to be creating a list of entries for the Chicago Cubs. So I stuck the
little 2-dimensional table (position, firstname, lastname) as the
return of a function called GetCubs and wrote this (based on listing
5.7):

class SimpleGrid(wx.grid.Grid):
    def __init__(self, parent):
        wx.grid.Grid.__init__(self, parent, -1)
        team=GetCubs()
        entries=[LineupEntry(man[0],man[1],man[2]) for man in team]
        self.SetTable(LineupTable, entries)

Then I found that the thing doesn't run and my error messages are
referencing line 1221 in some far flung corner of wx... So I have no
clue how to start unpicking this. Two questions:
- If you have done this example how did you make it work?
- Is there a general technique for dealing with these error messages
from out there in line 1221 of settable and so on.
Kind regards
Phil Ellis

Hi Phil,

···

On Nov 13, 12:29 pm, Philip Ellis <philipjel...@gmail.com> wrote:

Hi chaps
Has anyone made listing 5.10 work in Robin Dunn "the software
craftsman"'s book wxPython in Action?

This example seems to be a more useful implementation than the
previous examples, and so I had a go at making it work. The key seems
to be creating a list of entries for the Chicago Cubs. So I stuck the
little 2-dimensional table (position, firstname, lastname) as the
return of a function called GetCubs and wrote this (based on listing
5.7):

class SimpleGrid(wx.grid.Grid):
def __init__(self, parent):
wx.grid.Grid.__init__(self, parent, -1)
team=GetCubs()
entries=[LineupEntry(man[0],man[1],man[2]) for man in team]
self.SetTable(LineupTable, entries)

Then I found that the thing doesn't run and my error messages are
referencing line 1221 in some far flung corner of wx... So I have no
clue how to start unpicking this. Two questions:
- If you have done this example how did you make it work?
- Is there a general technique for dealing with these error messages
from out there in line 1221 of settable and so on.
Kind regards
Phil Ellis

Can you post the full traceback and attach the code? I'm sure it's
something simple.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

You probably want to do this instead:

      self.SetTable( LineupTable(entries) )

···

On 11/13/09 10:29 AM, Philip Ellis wrote:

Hi chaps
Has anyone made listing 5.10 work in Robin Dunn "the software
craftsman"'s book wxPython in Action?

This example seems to be a more useful implementation than the
previous examples, and so I had a go at making it work. The key seems
to be creating a list of entries for the Chicago Cubs. So I stuck the
little 2-dimensional table (position, firstname, lastname) as the
return of a function called GetCubs and wrote this (based on listing
5.7):

class SimpleGrid(wx.grid.Grid):
     def __init__(self, parent):
         wx.grid.Grid.__init__(self, parent, -1)
         team=GetCubs()
         entries=[LineupEntry(man[0],man[1],man[2]) for man in team]
         self.SetTable(LineupTable, entries)

--
Robin Dunn
Software Craftsman

Sorry to bother anyone that read this - I should have written
self.setTable(LineupTable(entries)) in the last line. Got confused.
It seems to work now.
Kind regards

Phil

···

On Nov 16, 8:53 am, Mike Driscoll <kyoso...@gmail.com> wrote:

Hi Phil,

On Nov 13, 12:29 pm, Philip Ellis <philipjel...@gmail.com> wrote:

> Hi chaps
> Has anyone made listing 5.10 work in Robin Dunn "the software
> craftsman"'s book wxPython in Action?

> This example seems to be a more useful implementation than the
> previous examples, and so I had a go at making it work. The key seems
> to be creating a list of entries for the Chicago Cubs. So I stuck the
> little 2-dimensional table (position, firstname, lastname) as the
> return of a function called GetCubs and wrote this (based on listing
> 5.7):

> class SimpleGrid(wx.grid.Grid):
> def __init__(self, parent):
> wx.grid.Grid.__init__(self, parent, -1)
> team=GetCubs()
> entries=[LineupEntry(man[0],man[1],man[2]) for man in team]
> self.SetTable(LineupTable, entries)

> Then I found that the thing doesn't run and my error messages are
> referencing line 1221 in some far flung corner of wx... So I have no
> clue how to start unpicking this. Two questions:
> - If you have done this example how did you make it work?
> - Is there a general technique for dealing with these error messages
> from out there in line 1221 of settable and so on.
> Kind regards
> Phil Ellis

Can you post the full traceback and attach the code? I'm sure it's
something simple.

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org