ObjectListView - Getting numbers into columns

Hi,

I just downloaded the ObjectListView widget and added it to a new program I am working on. For some reason though, only some of the columns have data in them. I suspect I set something up wrong, but it's not obvious to me what that something is. My program will be interfacing with Amazon Web Services to download data on various products that they list. Here's my "Book" model:

<code>

class Book(object):
    """
    Model of the Book object returned from Amazon Web Services. """
        def __init__(self, title, author, asin, detailPageUrl, mfg):
        self.asin = asin
        self.author = author
        self.detailPageUrl = detailPageUrl
        self.mfg = mfg self.title = title

</code>

And here's how I set it up in my main app:

<code>
def __init__(self, **kwargs):
        self.dataOlv = ObjectListView(self, wx.ID_ANY, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.setBooks()

def setBooks(self):
        self.dataOlv.SetColumns([
            ColumnDefn("Title", "left", 120, "title"),
            ColumnDefn("Author", "left", 100, "author"),
            ColumnDefn("ISBN", "right", 100, "isbn"),
            ColumnDefn("Details", "left", 120, "details"),
            ColumnDefn("Mfg", "left", 80, "mfg")
            ])
        self.dataOlv.SetObjects(self.products)
</code>

Finally, here's some sample data I am trying to put in:

[[u’Scarlet (The King Raven, Book 2)’, u’Stephen R. Lawhead’, ‘159554089X’, u’http://www.amazon.com/Scarlet-King-Raven-Book-2/dp/159554089X%3FSubscriptionId%3D1E0NBX4S8VV4SH7EG002%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D159554089X’, u’Thomas Nelson’], [u’Hood (King Raven Trilogy, Book 1)’, u’Stephen R. Lawhead’, ‘B00164EAY6’, u’http://www.amazon.com/Hood-King-Raven-Trilogy-Book/dp/B00164EAY6%3FSubscriptionId%3D1E0NBX4S8VV4SH7EG002%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB00164EAY6’, u’Thomas Nelson’]]

In the real app, I create a list of Book instances. Anyway, when the program is run, the Title, Author and Mfg columns are populated, but the other two are not. I currently don't care about the Details column and will probably drop it, but I would like the ISBN one to still show.

I am using wxPython 2.8.8.1 (msw-unicode), Python 2.5.2 on Windows XP. Let me know if you need additional details. Thanks!

Mike

Mike Driscoll wrote:

Hi,

I just downloaded the ObjectListView widget and added it to a new program I am working on. For some reason though, only some of the columns have data in them. I suspect I set something up wrong, but it's not obvious to me what that something is. My program will be interfacing with Amazon Web Services to download data on various products that they list. Here's my "Book" model:

<code>

class Book(object):
   """
   Model of the Book object returned from Amazon Web Services. """
      def __init__(self, title, author, asin, detailPageUrl, mfg):
       self.asin = asin
       self.author = author
       self.detailPageUrl = detailPageUrl
       self.mfg = mfg self.title = title

</code>

And here's how I set it up in my main app:

<code>
def __init__(self, **kwargs):
       self.dataOlv = ObjectListView(self, wx.ID_ANY, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
       self.setBooks()

def setBooks(self):
       self.dataOlv.SetColumns([
           ColumnDefn("Title", "left", 120, "title"),
           ColumnDefn("Author", "left", 100, "author"),
           ColumnDefn("ISBN", "right", 100, "isbn"),
           ColumnDefn("Details", "left", 120, "details"),

Your model does not define 'isbn' nor 'details' :wink: .

Werner

Werner,

Mike Driscoll wrote:

Hi,

I just downloaded the ObjectListView widget and added it to a new program I am working on. For some reason though, only some of the columns have data in them. I suspect I set something up wrong, but it's not obvious to me what that something is. My program will be interfacing with Amazon Web Services to download data on various products that they list. Here's my "Book" model:

<code>

class Book(object):
   """
   Model of the Book object returned from Amazon Web Services. """
      def __init__(self, title, author, asin, detailPageUrl, mfg):
       self.asin = asin
       self.author = author
       self.detailPageUrl = detailPageUrl
       self.mfg = mfg self.title = title

</code>

And here's how I set it up in my main app:

<code>
def __init__(self, **kwargs):
       self.dataOlv = ObjectListView(self, wx.ID_ANY, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
       self.setBooks()

def setBooks(self):
       self.dataOlv.SetColumns([
           ColumnDefn("Title", "left", 120, "title"),
           ColumnDefn("Author", "left", 100, "author"),
           ColumnDefn("ISBN", "right", 100, "isbn"),
           ColumnDefn("Details", "left", 120, "details"),

Your model does not define 'isbn' nor 'details' :wink: .

Werner

Drat! I thought I'd tried that already, but it works this time around...at least for the isbn. Thanks!

Mike

Mike,

Mike Driscoll wrote:
...

Drat! I thought I'd tried that already, but it works this time around...at least for the isbn. Thanks!

You could also use the valueGetter function, I have not used this yet, but it was pointed out to me by Philip, as I want to be able to get to SQLAlchemy relation columns.

http://objectlistview.sourceforge.net/python/recipes.html#recipe-partial

Werner