On Thu, Jul 2, 2009 at 3:06 AM, Ole Streicher <[email protected]>wrote:
> Hi Brian,
>
> I have also some layout problems with the Qt4 backend. The worst one is
> a SegFault when adjusting the width.
>
> Brian Zambrano <[email protected]> writes:
> > vbox = QVBoxLayout()
> > vbox.addWidget(self.canvas)
> > self.setLayout(vbox)
>
> Could you just try to add a second canvas to the layout?
>
> vbox = QVBoxLayout()
> vbox.addWidget(self.canvas1)
> vbox.addWidget(self.canvas2)
> self.setLayout(vbox)
>
> and then try to adjust the size by moving the separator between the
> central and right widget? In my code, I can reproduce a crash here on
> Linux. Also, depending on the speed (content) of the canvases, the width
> is not always ajusted correctly.
>
> I am still not sure whether this is fault of Qt, PyQt, or matplotlib.
>
I can't produce a segfault with the attached script. I have Qt-4.5.2,
PyQt-4.5.1, and a checkout of the matplotlib trunk.
Darren
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
from matplotlib.figure import Figure
class AppForm(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.create_dock_widgets()
self.create_main_frame()
self.resize(700, 600)
def create_dock_widgets(self):
right_widget = QDockWidget('Right Widget', self)
right_widget.setWidget(QListWidget())
self.addDockWidget(Qt.RightDockWidgetArea, right_widget)
bottom_widget = QDockWidget('Bottom Widget', self)
bottom_widget.setWidget(QListWidget())
self.addDockWidget(Qt.BottomDockWidgetArea, bottom_widget)
def create_main_frame(self):
w = PlotWidget()
self.setCentralWidget(w)
class PlotWidget(QWidget):
def __init__(self, parent=None):
super(PlotWidget, self).__init__(parent)
self.dpi = 100
self.fig = Figure((5.0, 4.0), dpi=self.dpi)
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
self.axes = self.fig.add_subplot(111)
self.canvas2 = FigureCanvas(self.fig)
self.canvas2.setParent(self)
vbox = QVBoxLayout()
vbox.addWidget(self.canvas)
vbox.addWidget(self.canvas2)
self.setLayout(vbox)
def main():
import sys
app = QApplication(sys.argv)
form = AppForm()
form.show()
app.exec_()
if __name__ == "__main__":
main()
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users