def addNavigationToolbar(): """Add the matplotlib QT navigation toolbar to the plot. """ plt = getPlot() if not plt: return # Check that the navigation toolbar has not been already created if plt.mpl_toolbar is not None: return # Create the navigation toolbar and add it plt.mpl_toolbar = NavigationToolbar(plt.canvas, plt) vbox = plt.layout() vbox.addWidget(plt.mpl_toolbar)
def delNavigationToolbar(): """Remove the matplotlib QT navigation toolbar from the plot. """ plt = getPlot() if not plt: return # Check that the navigation toolbar already exist if plt.mpl_toolbar is None: return # Remove the widget from the layout vbox = plt.layout() vbox.removeWidget(plt.mpl_toolbar) # Destroy the navigation toolbar plt.mpl_toolbar.deleteLater() plt.mpl_toolbar = None