Some reference code for handling Matplotlib GUI elements