26

The Observer Pattern

In our sophisticated windowing world, we often would like to display data in more than one form at the same time and have all the displays reflect any changes in that data. For example, we might represent stock price changes as both a graph and a table or listbox. Each time the price changes, we’d expect both representations to change at once without any action on our part.

We expect this sort of behavior because there are any number of Windows applications, such as Excel, where we see that behavior. Now, there is nothing inherent in Windows to allow this activity and, as you may know, programming directly in Windows in C or C++ is complicated. In Python, however, we can easily make use of the Observer design pattern ...

Get Python Programming with Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.