Hi Nils.

The Qt based Navigation toolbar is just a Qt Widget with a proper layout 
already set. So you should be able to add any Qt widget to the toolbar using 
its addWidget method.
I was able to add a simple line edit (without any use) like so:

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as 
NavigationToolbar2

class ViewWidget(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
    
        # create a simple main widget to keep the figure
        self.mainWidget = QWidget()
        self.setCentralWidget(self.mainWidget)

        layout = QVBoxLayout()
        self.mainWidget.setLayout(layout)

        # create a figure
        self.figure_canvas = FigureCanvas(Figure())
        layout.addWidget(self.figure_canvas, 10)

        # and the axes for the figure
        self.axes = self.figure_canvas.figure.add_subplot(111)

        # add a navigation toolbar
        self.navigation_toolbar = NavigationToolbar2(self.figure_canvas, self)
        layout.addWidget(self.navigation_toolbar, 0)

        # create a simple widget to extend the navigation toolbar
        anotherWidget=QLineEdit()
        # add the new widget to the existing navigation toolbar
        self.navigation_toolbar.addWidget(anotherWidget)
        
if __name__=="__main__":
    app=QApplication(sys.argv)
    mw=ViewWidget()
    mw.show()
    sys.exit(app.exec_())

Hope that helps ...

Best regards

Jens


-----Original Message-----
From: Nils Wagner [mailto:nwag...@iam.uni-stuttgart.de] 
Sent: Thursday, September 29, 2011 2:56 PM
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] Customizing the Navigation toolbar

Hi all,

How can I add a printer button to the Navigation toolbar 
http://matplotlib.sourceforge.net/users/navigation_toolbar.html
?

A small example for QT would be awesome.

Thanks in advance.

  Nils

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a 
definitive record of customers, application performance, security threats, 
fraudulent activity and more. Splunk takes this data and makes sense of it. 
Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to