MVC and DynamicSashWindow
Danny Shevitz
shevitz at lanl.gov
Thu Mar 1 07:39:10 PST 2007
I have a question on which I'd like to get persepectives concerning MVC.
This isn't
strictly a wxPython question, but I'm sure people on this list have dealt
with it.
I'm using a DSW to display a tree data structure. I already have a MVC
architecture
implemented, with an Observer/proxy class for my Model that runs underlying
model
methods and send messages back to the view via pubsub to notify when view
updates
are required.
My Observer knows nothing about the view, it just post messages which the
view interprets.
The wrinkle is that when I use a DSW, I don't want all the windows to do
the same thing. In particular,
I may not want to change the focus in the windows that I am not directly
editing. Example: I insert a node
in a particular window. Certainly in that window I want the selected item
to be the new node, but in
the other windows I probably want to keep the focus where it was. The
problem is that via the mechanism
I am currently using, all windows will get the message to change the focus.
I can think of two ways around this. 1) pass to the Observer the current
window, so that it knows to send a
different message to that window or 2) put the "select item" code in the
event handler, and don't delegate
that to the Observer.
The first method seems to violate the separation of concerns in MVC. The
second seems like it violates
the spirit of MVC since the gui is driving the display state, not the
underlying model.
Any opinions? I'd love to hear what people do and how they live with
themselves in good conscience.
thanks,
Danny
More information about the wxpython-users
mailing list