Book Image

Interactive Applications using Matplotlib

Book Image

Interactive Applications using Matplotlib

Overview of this book

Table of Contents (12 chapters)

Editor events


Let's now re-imagine our existing features as a set of events:

  • Change frame

  • Select storm

  • Deselect storm

  • Hide storm cells

  • Delete storm cell

  • Save storm data

  • Display help

We will add two new methods to the ControlSys class: _connect() and _emit(). They are merely shorthand for the mpl_connect() command and the recently introduced process() method. In the constructor, we will connect some methods to the events we have just listed. In the case of the help method and the storm saving method, the methods originally supplied to the keymap will be connected to these two new events, and the keymap will instead merely call _emit() of the respective events. This can give a taste of fully customizable keymaps in the future. Meanwhile, this is what our constructor and the two new _emit() and _connect() methods now look like:

Source: chp2/stormcell_editor2.py

class ControlSys(KeymapControl, PickControl):
    def __init__(self, fig, raddisp, data, polygons, stormdata):
        self.fig = fig
    ...