Demonstrate NavigationToolbar with GTK3 accessed via pygobject.
importgigi.require_version('Gtk','3.0')fromgi.repositoryimportGtkfrommatplotlib.backends.backend_gtk3import(NavigationToolbar2GTK3asNavigationToolbar)frommatplotlib.backends.backend_gtk3aggimport(FigureCanvasGTK3AggasFigureCanvas)frommatplotlib.figureimportFigureimportnumpyasnpwin=Gtk.Window()win.connect("delete-event",Gtk.main_quit)win.set_default_size(400,300)win.set_title("Embedding in GTK")f=Figure(figsize=(5,4),dpi=100)a=f.add_subplot(1,1,1)t=np.arange(0.0,3.0,0.01)s=np.sin(2*np.pi*t)a.plot(t,s)vbox=Gtk.VBox()win.add(vbox)# Add canvas to vboxcanvas=FigureCanvas(f)# a Gtk.DrawingAreavbox.pack_start(canvas,True,True,0)# Create toolbartoolbar=NavigationToolbar(canvas,win)vbox.pack_start(toolbar,False,False,0)win.show_all()Gtk.main()