Python made it easy to write the core of our application, but just about everything so far could have been done in one of many different languages. In this chapter, we move to one of Python’s greatest strengths: making applications extensible. In the process, we’ll learn a lot about how Python works internally.
Many popular applications (notably the Microsoft Office family) have a macro language that allows users to customize the way the application behaves. The kind of things users should be able to do are:
Users can write arbitrary scripts in Python that work with
These run from within our GUI application or independently.
Adding, editing, and deleting transactions are good candidates for events users can hook into.
Validation rules can get you closer to a robust accounting system. With the right events to trap, users can produce their own rules to ensure the validity of their data.
Some queries have been hardcoded into our system. You can generalize this concept to specify the inputs and outputs to a query and allow users to write their own. These would need some limitations, e.g., return a 2D array suitable for display in a grid.
If you start writing your application in a compiled language such as Visual Basic, Delphi, or Visual C++, you’ll find it hard to add the macro capability. Writing your own macro language is not a small task, and there ...