Hi Mike,
Yes, there is no DataListView in the python version. Even in .NET the whole
data binding topic is much easier to use than it is to implement.
Attached is a small example of browser/editor that shows the results of a
SELECT and allows the rows to be edited. It's not a rethink or a fresh
design - it's just an example of how something could be made to work with
ObjectListView.
The meat of the program is the DoSelect() method, which builds and populates
the ObjectListView with the last two lines of the method:
def DoSelect(self, stmt):
# Clear the existing query results
self.myOlv.SetObjects(list())
# Run the query
cur = self.connection.cursor()
cur.execute(stmt)
# Create a columnDefn for each column in the query.
# The value to be shown in a cell is the i'th value in the list
self.myOlv.SetColumns(ColumnDefn(x[0], valueGetter=i,
minimumWidth=40) for (i,x) in enumerate(cur.description))
# fetchall() returns tuples which can't be modified in place, so we
convert them to lists
self.myOlv.SetObjects([list(x) for x in cur.fetchall()])
The updating strategy uses the CELL_EDIT_FINISHED event, which is only
available in the SVN version of ObjectListView. So, either get hold of the
latest version, or comment out references to CELL_EDIT_FINISHED.
Hope this gives you some ideas.
Regards,
Phillip
SqlExample.py (7.74 KB)
···
------------------------------------------------------------------------
Phillip Piper www.bigfoot.com/~phillip_piper phillip_piper@bigfoot.com
A man's life does not consist in the abundance of his possessions
-----Original Message-----
From: wxpython-users-bounces@lists.wxwidgets.org
[mailto:wxpython-users-bounces@lists.wxwidgets.org] On Behalf Of Mike Rooney
Sent: Wednesday, 13 August 2008 7:15 PM
To: wxpython-users@lists.wxwidgets.org
Subject: Re: [wxpython-users] ANN: ObjectListView 1.1
[snip]
This looks really cool and I am thinking of porting one of my
applications that currently uses a wxGrid to use this instead.
Basically, I want an attractive and editable wrapper around the
resulting rows of a SQL query.
I notice the DataListView seems to be missing from the Python version,
am I correct? If so, any recommendations/recipes on getting the data
binding? Basically I was thinking of having the model create a custom
list class which presents itself to OLV, and ideally that could do all
the getting and setting like a DataListView. That custom list class
would then be sending pubsub messages on appends/removals/edits which
allows the appropriate SQL queries to take place in the database.
Any hints? I am trying to think of this from as much of a fresh, new
perspective as possible so I don't bring along any unnecessary paradigms
of my "pushing and pulling from a wxGrid" approach.
Thanks!
- Mike
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users