[wxPython-users] wxPython and MVC
Mark Erbaugh
mark at microenh.com
Thu Dec 6 05:46:08 PST 2007
On Thu, 2007-12-06 at 11:09 +0000, jonhattan wrote:
> I've a design based on MVP, Model-View-Presenter --there's some about
> mvp in the wiki.
>
Jonhatten,
Thank you for your explanation. I had discovered the MVP write up in the
wiki and I am working through it. I noticed that Martin Fowler has
depricated the MVP pattern:
http://martinfowler.com/eaaDev/ModelViewPresenter.html
and replaced it with Supervising Controller and Passive View patterns.
I haven't had time to study this yet.
I think I have essentially implemented the functionality of your
interactor. Currently, it resides as a method in my view (wx.Frame)
class, but I have been thinking of separating it from there. Basically,
the wx.Frame descendent has a method, SetController that takes an
instance of the controller and then binds events from the wx.Frame to
methods in the controller.
One refinement I made was the ability to un-bind the controller before
cleanup. I found a case where, depending on the order that things were
destroyed, an event handler tried to update a widget that had already
been destroyed. Fortunately, I was able to come up with generic
un-binding code that uses the same code as SetController, so the the
un-bind method is generic. That means that you only have to hand-code
the binding of event, you don't have to hand-code the un-binding.
As I mentioned, I've been thinking of moving SetController out of the
wx.Frame class. Actually, I'm thinking of moving the SetController
method to a sub-class of my wx.Frame sub-class. That way it would still
be able to access all the widgets via self. One reason I'm considering
this is I use a GUI design tool (wxGlade) to design the frame. By
splitting SetController and the other hand-coded routines into a
separate file, I can re-run wxGlade and allow it to completely re-write
it's Python output file. With the design I have now, I have to make sure
that wxGlade doesn't overwrite my hand-coded changes.
Mark
More information about the wxpython-users
mailing list