
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/user_interfaces/embedding_in_gtk3_panzoom_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_embedding_in_gtk3_panzoom_sgskip.py>`
        to download the full example code.

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

.. _sphx_glr_gallery_user_interfaces_embedding_in_gtk3_panzoom_sgskip.py:


=======================================
Embed in GTK3 with a navigation toolbar
=======================================

Demonstrate NavigationToolbar with GTK3 accessed via pygobject.

.. GENERATED FROM PYTHON SOURCE LINES 8-46

.. code-block:: Python


    import gi

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

    import numpy as np

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

    win = Gtk.Window()
    win.connect("delete-event", Gtk.main_quit)
    win.set_default_size(400, 300)
    win.set_title("Embedded in GTK3")

    fig = Figure(figsize=(5, 4), dpi=100)
    ax = fig.add_subplot(1, 1, 1)
    t = np.arange(0.0, 3.0, 0.01)
    s = np.sin(2*np.pi*t)
    ax.plot(t, s)

    vbox = Gtk.VBox()
    win.add(vbox)

    # Add canvas to vbox
    canvas = FigureCanvas(fig)  # a Gtk.DrawingArea
    vbox.pack_start(canvas, True, True, 0)

    # Create toolbar
    toolbar = NavigationToolbar(canvas)
    vbox.pack_start(toolbar, False, False, 0)

    win.show_all()
    Gtk.main()


.. _sphx_glr_download_gallery_user_interfaces_embedding_in_gtk3_panzoom_sgskip.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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