
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/user_interfaces/mpl_with_glade3_sgskip.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_user_interfaces_mpl_with_glade3_sgskip.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_user_interfaces_mpl_with_glade3_sgskip.py:


=======================
Matplotlib with Glade 3
=======================

.. GENERATED FROM PYTHON SOURCE LINES 6-55

.. code-block:: Python


    from pathlib import Path

    import gi

    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk

    import numpy as np

    from matplotlib.backends.backend_gtk3agg import \
        FigureCanvasGTK3Agg as FigureCanvas
    from matplotlib.figure import Figure


    class Window1Signals:
        def on_window1_destroy(self, widget):
            Gtk.main_quit()


    def main():
        builder = Gtk.Builder()
        builder.add_objects_from_file(
            str(Path(__file__).parent / "mpl_with_glade3.glade"),
            ("window1", ""))
        builder.connect_signals(Window1Signals())
        window = builder.get_object("window1")
        sw = builder.get_object("scrolledwindow1")

        # Start of Matplotlib specific code
        figure = Figure(figsize=(8, 6), dpi=71)
        axis = figure.add_subplot()
        t = np.arange(0.0, 3.0, 0.01)
        s = np.sin(2*np.pi*t)
        axis.plot(t, s)

        axis.set_xlabel('time [s]')
        axis.set_ylabel('voltage [V]')

        canvas = FigureCanvas(figure)  # a Gtk.DrawingArea
        canvas.set_size_request(800, 600)
        sw.add(canvas)
        # End of Matplotlib specific code

        window.show_all()
        Gtk.main()

    if __name__ == "__main__":
        main()


.. _sphx_glr_download_gallery_user_interfaces_mpl_with_glade3_sgskip.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

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

    .. container:: sphx-glr-download sphx-glr-download-python

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

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: mpl_with_glade3_sgskip.zip <mpl_with_glade3_sgskip.zip>`


.. only:: html

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

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
