Chicago Cubs - a standalone model class

2 views
Skip to first unread message

Philip Ellis

unread,
Nov 13, 2009, 1:29:14 PM11/13/09
to wxPython-users
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

Mike Driscoll

unread,
Nov 16, 2009, 9:53:54 AM11/16/09
to wxPython-users
Hi Phil,
Can you post the full traceback and attach the code? I'm sure it's
something simple.

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

Blog: http://blog.pythonlibrary.org

Robin Dunn

unread,
Nov 16, 2009, 1:32:13 PM11/16/09
to wxpytho...@googlegroups.com
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)

You probably want to do this instead:

self.SetTable( LineupTable(entries) )

--
Robin Dunn
Software Craftsman
http://wxPython.org

Philip Ellis

unread,
Nov 16, 2009, 2:57:01 PM11/16/09
to wxPython-users
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
Reply all
Reply to author
Forward
0 new messages