

.. _sphx_glr_gallery_event_handling_close_event.py:


===========
Close Event
===========





.. image:: /gallery/event_handling/images/sphx_glr_close_event_001.png
    :align: center





.. code-block:: python

    from __future__ import print_function
    import matplotlib.pyplot as plt


    def handle_close(evt):
        print('Closed Figure!')

    fig = plt.figure()
    fig.canvas.mpl_connect('close_event', handle_close)

    plt.text(0.35, 0.5, 'Close Me!', dict(size=30))
    plt.show()

**Total running time of the script:** ( 0 minutes  0.032 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: close_event.py <close_event.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: close_event.ipynb <close_event.ipynb>`

.. rst-class:: sphx-glr-signature

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
