Suggestions for wxPython Widget

32 views
Skip to first unread message

Rich Shepard

unread,
Feb 24, 2015, 5:42:15 PM2/24/15
to wxpytho...@googlegroups.com
After spending a lot of time creating a notebook with nested pages each
holding a variable number of data entry widgets I now realize that this is
not the correct approach. The notebook with nested pages will work well, but
what's really needed is a widget that displays all rows in the backend
database table. There are several in the wxPython-3.0.0.0 and since I've no
experience with any of them I'd appreciate your thoughts.

I suspect that what I want is one of the DVC (DataViewCtrl) widgets or a
list control. What criteria do I apply to decide which might be the most
appropriate for entering (and editing) variable types of data?

Pointers to example applications using these widgets would be nice.

TIA,

Rich

C M

unread,
Feb 24, 2015, 6:01:45 PM2/24/15
to wxpytho...@googlegroups.com
Hi Rich,

Offhand, it seems like they all do about the same thing relative to your needs: show rows and column headers. I tend to think in terms of grids when browsing databases (such as with SQLite Database Browser), so then I guess wxGrid would be good, and found this write-up about using it with an SQLite database:

http://www.salstat.com/news/linking-wxgrid-to-sqlite-database-in-python-an-example

Che

Rich Shepard

unread,
Feb 24, 2015, 6:39:16 PM2/24/15
to wxpytho...@googlegroups.com
On Tue, 24 Feb 2015, C M wrote:

> Offhand, it seems like they all do about the same thing relative to your
> needs: show rows and column headers. I tend to think in terms of grids
> when browsing databases (such as with SQLite Database Browser), so then I
> guess wxGrid would be good, and found this write-up about using it with an
> SQLite database:
> http://www.salstat.com/news/linking-wxgrid-to-sqlite-database-in-python-an-example

Che,

Thanks. Considering that example was written last autumn I'm surprised he
uses wx.PySimpleApp() as that's been deprecated.

I'll be using SQLAlchemy between the UI and the backend database so it
seems that wx.Grid() is the way to go. I can put a grid on the panel rather
than the wx.TextCtrl() and wx.ComboBox() widgets. Perhaps I can even put a
choice or combobox in a cell when there's a limited and defined list of
valid entries for that column. Think there's sample code on the Wiki site.

Then all I need are Add/Edit/Deactivate buttons for each page, and those
can be in a separate class and called with pubsub.

Thanks,

Rich

Mike Driscoll

unread,
Feb 25, 2015, 9:14:55 AM2/25/15
to wxpytho...@googlegroups.com

I actually tend to use ObjectListView, a wrapper for wx.ListCtrl to work with databases. But I also like to use SQLAlchemy which has classes that are similar to the ones I use in ObjectListView. Anyway, here's a link to a tutorial I did on the subject a while ago:

http://www.blog.pythonlibrary.org/2011/11/10/wxpython-and-sqlalchemy-an-intro-to-mvc-and-crud/

ObjectListView can be found here: http://objectlistview-python-edition.readthedocs.org/en/latest/

- Mike

Rich Shepard

unread,
Feb 25, 2015, 9:23:18 AM2/25/15
to wxpytho...@googlegroups.com
On Wed, 25 Feb 2015, Mike Driscoll wrote:

> I actually tend to use ObjectListView, a wrapper for wx.ListCtrl to work
> with databases. But I also like to use SQLAlchemy which has classes that
> are similar to the ones I use in ObjectListView. Anyway, here's a link to
> a tutorial I did on the subject a while ago:
>
> http://www.blog.pythonlibrary.org/2011/11/10/wxpython-and-sqlalchemy-an-intro-to-mvc-and-crud/
>
> ObjectListView can be found here:
> http://objectlistview-python-edition.readthedocs.org/en/latest/

Mike,

I've read your tutorial ... several times. If I understand it, both OLV
and SA are compatible. Not sure if OLV is limited to a single table column
or can display entire table rows. I'll look again, but today other projects
have priority.

The application supports my environmental consulting business, but is not
the focus of my business so learning the most expeditious and robust way to
structure the application is taking time.

Thanks very much,

Rich

Mike Driscoll

unread,
Feb 25, 2015, 9:30:25 AM2/25/15
to wxpytho...@googlegroups.com


On Wednesday, February 25, 2015 at 8:23:18 AM UTC-6, fuzzydoc wrote:
On Wed, 25 Feb 2015, Mike Driscoll wrote:

> I actually tend to use ObjectListView, a wrapper for wx.ListCtrl to work
> with databases. But I also like to use SQLAlchemy which has classes that
> are similar to the ones I use in ObjectListView. Anyway, here's a link to
> a tutorial I did on the subject a while ago:
>
> http://www.blog.pythonlibrary.org/2011/11/10/wxpython-and-sqlalchemy-an-intro-to-mvc-and-crud/
>
> ObjectListView can be found here:
> http://objectlistview-python-edition.readthedocs.org/en/latest/

Mike,

   I've read your tutorial ... several times. If I understand it, both OLV
and SA are compatible. Not sure if OLV is limited to a single table column
or can display entire table rows. I'll look again, but today other projects
have priority.

It can easily display multiple columns and rows. I wrote this fun little tutorial to demonstrate how flexible it is:

http://www.blog.pythonlibrary.org/2012/06/04/wxpython-and-sqlalchemy-loading-random-sqlite-databases-for-viewing/

This should open most SQLite databases. I think I ran into a few oddballs with some of Firefox's examples, but it worked for everything else I tested it with.

- Mike

Rich Shepard

unread,
Feb 25, 2015, 10:51:41 AM2/25/15
to wxpytho...@googlegroups.com
Mike,

Thanks! I'll be sure to read it.

After I get the SQLite version up and running I hope to just change the
back-end to postgres in SA and have a multi-user/client-server running.

Regards,

Rich

Werner

unread,
Feb 25, 2015, 10:58:10 AM2/25/15
to wxpytho...@googlegroups.com
On 2/25/2015 15:23, Rich Shepard wrote:
> On Wed, 25 Feb 2015, Mike Driscoll wrote:
>
...
> Mike,
>
> I've read your tutorial ... several times. If I understand it, both OLV
> and SA are compatible. Not sure if OLV is limited to a single table
> column
> or can display entire table rows.
Can have multiple rows, rows can even come from related tables.

Thought we had an example on how to do related tables but it doesn't
look like it.

Werner

--

Niderenweg 6
CH-9043 Trogen

Tel: +41 71 340 06 30
Mob: +41 76 374 81 07

Werner

unread,
Feb 25, 2015, 11:00:55 AM2/25/15
to wxpytho...@googlegroups.com
On 2/25/2015 16:58, Werner wrote:
> On 2/25/2015 15:23, Rich Shepard wrote:
>> On Wed, 25 Feb 2015, Mike Driscoll wrote:
>>
> ...
>> Mike,
>>
>> I've read your tutorial ... several times. If I understand it, both
>> OLV
>> and SA are compatible. Not sure if OLV is limited to a single table
>> column
>> or can display entire table rows.
> Can have multiple rows, rows can even come from related tables.
>
> Thought we had an example on how to do related tables but it doesn't
> look like it.
in medialocker

Werner

Rich Shepard

unread,
Feb 25, 2015, 11:38:01 AM2/25/15
to wxpytho...@googlegroups.com
On Wed, 25 Feb 2015, Werner wrote:

> Can have multiple rows, rows can even come from related tables. Thought we
> had an example on how to do related tables but it doesn't look like it.

Werner,

Thanks, again!

Rich
Reply all
Reply to author
Forward
0 new messages