When I create a figure in matplotlib I get these nice tools to move the graph around zoom in and out ect. However the only way I know how to put the figure into a GTK GUI is by converting it to a drawing area. When I convert I obviously lose the nice tools.
Is there a better way of putting a matplotlib figure into a GTK GUI so I can keep the tools?


This is an example, hope it helps:
from matplotlib.figure import Figure as F
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FC
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NT
import gtk
fig = F()
ax = fig.add_subplot(111)
ax.plot(range(10),range(10))
main = gtk.Window()
main.set_default_size(800,600)
main.connect("destroy", gtk.main_quit)
box = gtk.VBox()
main.add(box)
fc = FC(fig)
box.pack_start(fc)
nt = NT(fc, main)
box.pack_start(nt, expand=False, fill=False)
main.show_all()
gtk.main()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With