Hi everybody,
The following is a small test yielding a segmentation fault with PySide, but
not with PyQt4.
To test with PyQt4, use:
$ python example.py
To test with PySide:
$ python example.py pyside
With PySide, a segmentation fault appears as soon as the mouse cursor is
hovering the plot area. Without the NavigationToolbar (try to comment the
corresponding lines), the problem does not appear. It may be related to the
display of mouse coordinates in the NavigationToolbar, because when the mouse
is hovering the NavigationToolbar, no segfault appears.
These are the versions of Qt, PySide, and Matplotlib on my machine:
from PySide import QtCore
QtCore.qVersion()
'4.8.1'
from PySide import __version__
__version__
'1.1.0'
import matplotlib
matplotlib.__version__
'1.1.1rc'
Is this a bug? If yes, does any workaround exist?
Thanks in advance,
TP
########### example.py ############
#!/usr/bin/env python
import sys
if len(sys.argv) >= 2 and sys.argv[1] == "pyside":
from os import environ
environ['QT_API'] = 'pyside'
from PySide.QtCore import *
from PySide.QtGui import *
else:
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 NavigationToolbar2QTAgg
class MplCanvasXY( FigureCanvas ):
def __init__( self, title = None, xlabel = None, ylabel = None,
parent=None ):
self.fig = Figure()
self.axes = self.fig.add_subplot(111)
self.axes.grid(True)
FigureCanvas.__init__( self, self.fig )
self.setParent( parent )
app = QApplication( sys.argv )
d = QDialog()
vb = QVBoxLayout()
canvas = MplCanvasXY()
vb.addWidget( canvas )
navigationToolbar = NavigationToolbar2QTAgg(
parent = canvas
, canvas = canvas )
vb.addWidget( navigationToolbar )
d.setLayout( vb )
d.show()
sys.exit( app.exec_() )