I've been playing with wxPython for a while now, and I think that I'm ready to
put together a real app. I normally do mostly server-side work, so I'm a bit
new to GUI programming and *very* new to wx.
I already have some business objects that encapsulate the data and behavior of
the domain. In the UI, the user will be editing properties of these business
objects, but there may be multiple visible or hidden controls whose view is
affected by a change. For example, say we have a fairly standard set up: a
vertical splitter with a navigation tree on the left and a horizontal
splitter on the right with a list control on top and a properties panel
(multiple controls for editing an item's properties) on bottom.
Now, when the user clicks on the navigation control and then selects an item
in the list control, all of the property fields need to be populated based on
that item. As the user edits those properties, the changes need to be
reflected in the business object, and these changes may impact the
information displayed in the list control and in the navigation tree.
I know that some sort of model-view-controller/observer pattern works well in
this type of situation, but I'm wondering whether there's a standard way to
implement MVC with wxPython. For example, do you write a controller object
that implements some sort of observable API with an explicit list of
observers to notify whenever the controlled business object changes? Or do
you just push the observable behavior down into the business objects
themselves? How do you connect the business objects with the controls that
need to be updated? Do you just maintain a list of observers that have asked
to be notified in the observable object/controller? Or do you use the wx
event system to send notification that a business object was updated and then
make all of the controls listen for those changes? When pushing data back
and forth between the business objects and the GUI controls, do you make a
Panel subclass that shows all of the properties for a specific business class
and handles pushing data back and forth to standard wx controls? Or do you
subclass each control, so that you have MySocialSecurityNumberTextCtrl and
MyEmployeeDepartmentCodeCombCtrl and such?
Or are all of these suggestions valid and used by various applications
depending on the needs?
Thanks,
---Tom