I would like to create a navigation Toolbar in my PyQt4 GUI but I can't make it work, I must admit that I mostly copy-pasted this code and I don't really get it. Would be great if you could tell me how to add the NavigationToolbar and explain how it was made. Thank you in advance.
Btw. I have seen This Post but I believe it's different from mine and I can't figure out how to use it.
from PyQt4 import QtGui
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class MplCanvas(FigureCanvas):
def __init__( self ):
self.fig = Figure()
self.ax = self.fig.add_subplot( 111 )
FigureCanvas.__init__( self, self.fig )
FigureCanvas.setSizePolicy( self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding )
FigureCanvas.updateGeometry( self )
class matplotlibWidget(QtGui.QWidget):
def __init__( self, parent = None ):
QtGui.QWidget.__init__( self, parent )
self.canvas = MplCanvas()
#self.toolbar = self.canvas.toolbar #Dunno How :(
self.vbl = QtGui.QVBoxLayout()
self.vbl.addWidget( self.canvas )
self.setLayout( self.vbl )