I am reading the WXPyhon In Action Rapin/Dun Book.
And I would like to adapt methods specialy the GetValue() of
GenericTable object (p133) for using an other kind
of data wich is not a tuple of tuble but a
query.all() or a query.fiter_by from SQLalchemy interface.
I am reading the WXPyhon In Action Rapin/Dun Book. And I would like to adapt methods specialy the GetValue() of
GenericTable object (p133) for using an other kind of data wich is not a tuple of tuble but a
query.all() or a query.fiter_by from SQLalchemy interface.
I could make a tuple of tuble, as an intermediate, from the
query.all(). But is there any more pythonistic code
thanks for your help
I would recommend the sqlalchemy mailing list (Page Moved) for this question. You'll probably just have to create some indexer yourself unless SQLA has one built in.
I am reading the WXPyhon In Action Rapin/Dun Book. And I would like to adapt methods specialy the GetValue() of
GenericTable object (p133) for using an other kind of data wich is not a tuple of tuble but a
query.all() or a query.fiter_by from SQLalchemy interface.
I could make a tuple of tuble, as an intermediate, from the
query.all().
The only requirement of GetValue is that it returns the value to be displayed for the cell at the given row/col. How it does that or where it fetches the values from is entirely up to you. The sample in the book is using a simple sequence of sequences because the sample is not trying to show you how to manage data, but rather how to integrate it into a Grid widget.
My suggestion would be to take a step back and look at the structure of the data you want to display and what format it is in when you get it from the DB. Think about how that maps to the rows/cols that will be on screen, and then write a GetValue that does that mapping. In the book that is done with self.data[row][col]. In your case it might be something that is very specific to your data model, for example:
obj = self.dataModel.lastQuery().getItem(row)
text = [obj.id, obj.name, obj.description][col]
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!