DataViewModel: show more item column values for parents

hello, I’m playing with DataViewModel to verify if it suits my needs. I’ve modified the DVC_DataViewModel demo script so that Genre objects could show another member value (called ‘descr’). So, reading the code and its comments I’ve changed the script in two places:

1: modified the Genre object constructor
class Genre(object):
def init(self, name):
self.name = name
self.descr =‘foo’ #<-------added this
self.songs = []

2:added node.descr in the list of fields to show in GetValue
def GetValue(self, item, col):
node = self.ItemToObject(item)
if isinstance(node, Genre):
mapper = { 0 : node.name,
1 : node.descr, #<---------changed this
2 : “”,
3 : “”,
4 : wx.DateTimeFromTimeT(0), # TODO: There should be some way to indicate a null value…
5 : False,
}
return mapper[col]
…[omissis]

but the descr values are not shown. Why?

thanks in advance for help

Marco

def HasContainerColumns(self, item):

return True

is commented out in the demo, uncomment it out and your containers will show

Chris

···

On Wednesday, August 22, 2012 6:45:30 AM UTC-4, Marco Prosperi wrote:

hello, I’m playing with DataViewModel to verify if it suits my needs. I’ve modified the DVC_DataViewModel demo script so that Genre objects could show another member value (called ‘descr’). So, reading the code and its comments I’ve changed the script in two places:

1: modified the Genre object constructor
class Genre(object):
def init(self, name):
self.name = name
self.descr =‘foo’ #<-------added this
self.songs =

2:added node.descr in the list of fields to show in GetValue
def GetValue(self, item, col):
node = self.ItemToObject(item)
if isinstance(node, Genre):
mapper = { 0 : node.name,
1 : node.descr, #<---------changed this
2 : “”,
3 : “”,
4 : wx.DateTimeFromTimeT(0), # TODO: There should be some way to indicate a null value…
5 : False,
}
return mapper[col]
…[omissis]

but the descr values are not shown. Why?

thanks in advance for help

Marco