ModelView wx-way or own-way?

I knew the theoretical background of the MVC-Pattern.
I used it with C++ years ago.
So I am quite familiar with it.

About wxPython I read
<http://www.wiki.wxpython.org/ModelViewController/>
This is a python-specific description/tutorial about the MVC-pattern.
But it doesn't use wx-classes (except in the UI-layer).

But I read about the Document/View Framework in wxWidgets
<http://docs.wxwidgets.org/trunk/overview_docview.html>

The questions is, should I use the wx-way for MVC, or should I
implement it myself like the first description in the wxPyWiki
explained?

What do you prefere in your productive daily work?

There have been a few discussions on this list on that subject in the past.

The one which helped me getting my code better organized was the thread "Separating GUI code from Logic" a few years ago.

Werner

···

On 2/7/2015 19:28, moonkid@posteo.org wrote:

I knew the theoretical background of the MVC-Pattern.
I used it with C++ years ago.
So I am quite familiar with it.

About wxPython I read
<http://www.wiki.wxpython.org/ModelViewController/&gt;
This is a python-specific description/tutorial about the MVC-pattern.
But it doesn't use wx-classes (except in the UI-layer).

But I read about the Document/View Framework in wxWidgets
<http://docs.wxwidgets.org/trunk/overview_docview.html&gt;

The questions is, should I use the wx-way for MVC, or should I
implement it myself like the first description in the wxPyWiki
explained?

What do you prefere in your productive daily work?

I believe Werner is referring to this thread: Redirecting to Google Groups

You may also find this old tutorial helpful: http://www.blog.pythonlibrary.org/2011/11/10/wxpython-and-sqlalchemy-an-intro-to-mvc-and-crud/

Werner and I ended up spinning that article off into a demo of MVC (sort of) called MediaLocker - Improving MediaLocker: wxPython, SQLAlchemy, and MVC - Mouse Vs Python

I hope they help in some way.
Mike

···

On Saturday, February 7, 2015 at 3:56:29 PM UTC-6, werner wrote:

On 2/7/2015 19:28, moo...@posteo.org wrote:

I knew the theoretical background of the MVC-Pattern.

I used it with C++ years ago.

So I am quite familiar with it.

About wxPython I read

<http://www.wiki.wxpython.org/ModelViewController/>

This is a python-specific description/tutorial about the MVC-pattern.

But it doesn’t use wx-classes (except in the UI-layer).

But I read about the Document/View Framework in wxWidgets

<http://docs.wxwidgets.org/trunk/overview_docview.html>

The questions is, should I use the wx-way for MVC, or should I

implement it myself like the first description in the wxPyWiki

explained?

What do you prefere in your productive daily work?

There have been a few discussions on this list on that subject in the past.

The one which helped me getting my code better organized was the thread
“Separating GUI code from Logic” a few years ago.

Werner

Hi Mike

···

On 2015-02-09 06:39 Mike Driscoll <kyosohma@gmail.com> wrote:

Werner and I ended up spinning that article off into a demo of MVC
(sort of) called MediaLocker -
Improving MediaLocker: wxPython, SQLAlchemy, and MVC - Mouse Vs Python

Thank you very much. wx & sqlalchemy is exactly what I am using
currently. :wink:

There is one line in the blog-article
"an example of a wxPython database-enabled application"

Does this mean there is somewhere an official example in the office
wxPython docs? I couldn't find something like that.

Yes, that was a reference to the MediaLocker project - https://bitbucket.org/driscollis/medialocker/src

The second article I linked to (http://www.blog.pythonlibrary.org/2011/11/30/improving-medialocker-wxpython-sqlalchemy-and-mvc/) had a bunch of fixes to the original one. Then Werner took the changes in that second article and added a bunch more. It’s really interesting to see how it changed.

Mike

···

On Monday, February 9, 2015 at 9:36:20 AM UTC-6, moo...@posteo.org wrote:

Hi Mike

On 2015-02-09 06:39 Mike Driscoll kyos...@gmail.com wrote:

Werner and I ended up spinning that article off into a demo of MVC

(sort of) called MediaLocker -
http://www.blog.pythonlibrary.org/2011/11/30/improving-medialocker-wxpython-sqlalchemy-and-mvc/

Thank you very much. wx & sqlalchemy is exactly what I am using

currently. :wink:

There is one line in the blog-article

“an example of a wxPython database-enabled application”

Does this mean there is somewhere an official example in the office

wxPython docs? I couldn’t find something like that.

My apologies if that last one got copied to your email. Google Groups web interface seems to do that automatically and I don’t always notice the checkbox.

Mike

You’ve got some nice pointers, but to answer your question directly:

···

About wxPython I read

<http://www.wiki.wxpython.org/ModelViewController/>

This is a python-specific description/tutorial about the MVC-pattern.

But it doesn’t use wx-classes (except in the UI-layer).

But I read about the Document/View Framework in wxWidgets

<http://docs.wxwidgets.org/trunk/overview_docview.html>

The questions is, should I use the wx-way for MVC, or should I

implement it myself like the first description in the wxPyWiki

explained?

I would go with using pure-python for everything except the UI layer.

  1. It’s a good rule of thumb to use the the python-way for thigns that are supported in both C++ wx and python itself.

  2. One of the reasons to do MVC is to keep GUI-logic completely independent of the rest of the app, so that you could swap out another GUI, pure text API, Web API, etc. In that case, you don’t want to be relying on anything from wx outside of the GUI itself.

  3. IMHO, MVC “frameworks” don’t really give you much over rolling your own, application-specific structure – particularly in Python.

-HTH,

-Chris

What do you prefere in your productive daily work?

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris Barker wrote:

You've got some nice pointers, but to answer your question directly:

    About wxPython I read
    <http://www.wiki.wxpython.org/ModelViewController/&gt;
    This is a python-specific description/tutorial about the MVC-pattern.
    But it doesn't use wx-classes (except in the UI-layer).

    But I read about the Document/View Framework in wxWidgets
    <http://docs.wxwidgets.org/trunk/overview_docview.html&gt;

    The questions is, should I use the wx-way for MVC, or should I
    implement it myself like the first description in the wxPyWiki
    explained?

I would go with using pure-python for everything except the UI layer.

1) It's a good rule of thumb to use the the python-way for thigns that
are supported in both C++ wx and python itself.

2) One of the reasons to do MVC is to keep GUI-logic completely
independent of the rest of the app, so that you could swap out another
GUI, pure text API, Web API, etc. In that case, you don't want to be
relying on anything from wx outside of the GUI itself.

3) IMHO, MVC "frameworks" don't really give you much over rolling your
own, application-specific structure -- particularly in Python.

And to throw yet another log on the fire, wx's docview framework was ported to Python code so it is more or less a pure python implementation of that pattern. See wx.lib.docview and wx.lib.pydocview for a bit of extra pythonification on top of docview. Personally the pattern has never gelled with me like some of the others do, but it's there if anybody wants to use it.

···

--
Robin Dunn
Software Craftsman