Hi all,

maybe I am wrong in this mailing list but perhaps someone of you know any solutions or got similar problems.

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.
****************************************************************************
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to