Chapter 6. Properties, dialogs, and Visual Studio

 

This chapter covers

  • Properties in Python
  • The observer pattern
  • Windows Forms dialogs
  • Using Visual Studio with IronPython
  • Object serialization

In the last chapter, you added to the MultiDoc codebase the ability to load and save multiple pages with XML. Alas, we didn’t have the chance to give the user access to your work. In this chapter, we bring life to the skeleton of the MultiDoc framework by clothing it with the flesh of additional features and functionality. Some of these features will require the refactoring of classes you’ve already written. In the process, you’ll learn more about Python and get to use Visual Studio with IronPython plus some .NET classes that you haven’t seen yet.

Although you’ve extended MultiDoc to read and write XML files, you still don’t have a way of updating all the parts of the code that need access to documents. It’s the responsibility of the tab controller to keep the view and the model synchronized; it needs a way of updating the view when the model is changed. The save commands also need a reference to the current document. You can provide this by making some classes document observers.

6.1. Document observers

The model classes should remain loosely coupled to the view and controllers (a substantial part of the Model-View-Controller pattern), so you can’t give the document the responsibility for telling the tab controller to update the view.

6.2. More with TabPages: dialogs and Visual Studio

6.3. Object serializing with BinaryFormatter

6.4. Summary

sitemap