[PyKDE] PyQT and Rpy crashes by using in abstrakt methods

Matthias Frick matthias.frick at rsel.renesas.com
Wed Aug 9 11:04:03 BST 2006


Hi all,

I got an problem using an R function call in an function which overwrite 
an abstrakt function of the QtCore.QAbstractTableModel.  (QT 4.1.3 and 
Pyhton 2.4, tested with several R versions)

Running the following script get following result: the windows crashes 
and the commandline show this:

    3
    3
    3
    3
     >Exit code: 1073807364


Maybe someone off you can help me:

Here is the code: Look at line 37: print with_mode(BASIC_CONVERSION, 
r.dim)(self._dataFrame)[0]
If I comment this line all work fine ...
But the R function out of the abstrakt GUI function work fine too.

Regards
Matthias

---------------------------------------------------------

import sys
from PyQt4 import QtCore, QtGui

from rpy import *

class QagsDataFrameModel(QtCore.QAbstractTableModel):
    def __init__(self, data_frame, parent = None):
        QtCore.QAbstractTableModel.__init__(self, parent)

        self._dataFrame = data_frame

    def columnCount(self, parent):
        return 2

    def data(self, index, role):
        if not index.isValid():
            return QtCore.QVariant()
        if role != QtCore.Qt.DisplayRole:
            return QtCore.QVariant()
        return QtCore.QVariant("2")


    def headerData(self, section, orientation, role):
        header_names = ("s", "d")
        if orientation == QtCore.Qt.Horizontal and role == 
QtCore.Qt.DisplayRole:
            if section in range(len(header_names)):
                return QtCore.QVariant(header_names[section])
            else:
                return QtCore.QVariant()
        return QtCore.QVariant()

    def rowCount(self, parent):
        #
        # Look HERE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        #
        #Here I call an R function:
        print with_mode(BASIC_CONVERSION, r.dim)(self._dataFrame)[0]
        return 3


class MainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
   
        self.fileMenu = self.menuBar().addMenu(self.tr("&File"))
   
        self.fileMenu.addAction(self.tr("E&xit"), 
self,QtCore.SLOT("close()"), QtGui.QKeySequence(self.tr("Ctrl+Q")))
   
        df = with_mode(NO_CONVERSION, 
r)("data.frame(x=c(1,2,3),y=c(2,3,4))")
        self._model = QagsDataFrameModel(df, self)
   
        self._view = QtGui.QTableView(self)
        self._view.setModel(self._model)
   
        self.setCentralWidget(self._view)
        self.setWindowTitle(self.tr("Simple DataFrame Model"))


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    window = MainWindow()
    window.resize(640, 480)
    window.show()
    sys.exit(app.exec_())


****************************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance on
it, is prohibited.
E-mail messages are not necessarily secure.  Renesas does not accept
responsibility for any changes made to this message after it was sent.
Please note that this email message has been swept by Renesas for
the presence of computer viruses.
****************************************************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060809/4cc3640a/attachment.html


More information about the PyQt mailing list