|
From: RICHARD Georges-E. <per...@gm...> - 2011-08-11 06:38:01
|
First of all congratulation for the release 1.1.0 of matplotlib it's a wonderfull. since the version 0.90 I started to use it, I keep enjoy it everyday. I work with PyQT4 and PySide. I try to modify the height of the NavigationToolbar2QT, but no matter I use "resize" the Qt4 method nothing happen. code available: http://pastebin.com/8KW2dWG2 #...# all Qt imports from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4 import NavigationToolbar2QT as NavigationToolbar class MPL_widget(QWidget): def __init__(self,parent): QWidget.__init__(self,parent) self.canvas = FigureCanvas() self.toolbar = NavigationToolbar(self.canvas,self.canvas) self.toolbar.resize(100,10) # self.vbox = QVBoxLayout() vbox = self.vbox vbox.addWidget(self.canvas) vbox.addWidget(self.toolbar) self.setLayout(vbox) I tryed to modify directly in matplotlib module 'matplotlib.backends.backed_qt4' in the constructor of NavigationToolbar2QT just after the call of QToolBar.__init__(), nothing happen either. finaly I added a QSplitter, which let me hide the bar during runtime, but my first goal was rather to reduce the size and all icon inside. from PyQt4.QtCore import * from PyQt4.QtGui import * import PyQt4.QtGui as QtGui import matplotlib if matplotlib.get_backend() != "Qt4Agg": matplotlib.use("Qt4Agg") from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4 import NavigationToolbar2QT as NavigationToolbar from matplotlib.figure import Figure class MPL_Widget(QWidget): def __init__(self, parent = None): QWidget.__init__(self, parent) self.fig = Figure(figsize = (10, 12), dpi=100, facecolor = '#FFFFFF') self.ax = self.fig.add_subplot(111, sharex = None, sharey = None) self.canvas = FigureCanvas(self.fig) self.toolbar = NavigationToolbar(self.canvas, self.canvas) self.toolbar.resize(10,10) # this line does nothing self.vbox = QVBoxLayout() tmp = self.vbox tmp = QSplitter() tmp.setOrientation(Qt.Vertical) tmp.setContentsMargins(0,0,0,0) tmp.addWidget(self.canvas) tmp.addWidget(self.toolbar) self.vbox.addWidget(tmp) self.setLayout(self.vbox) self.layout().setContentsMargins(0,0,0,0) import sys app = QApplication(sys.argv) w = MPL_Widget() import numpy as N x = N.linspace(-10, 10) y = N.sin(x) ax = w.ax ax.plot(x, y, 'o-', mew=0) w.show() sys.exit(app.exec_()) Any hint would be appreciate. Cheers. Joe -- RICHARD Georges-Emmanuel Electronic and Computer Engineer per...@gm... |