[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyKDE] PyQT and Rpy crashes by using in abstrakt methods
From:       "Matthias Frick" <matthias.frick () rsel ! renesas ! com>
Date:       2006-08-09 10:04:03
Message-ID: 44D9B313.10408 () rsel ! renesas ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.
****************************************************************************


[Attachment #5 (text/html)]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-15"
 http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi all,<br>
<br>
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)<br>
<br>
Running the following script get following result: the windows crashes
and the commandline show this:<br>
<blockquote><small>3<br>
3<br>
3<br>
3<br>
&gt;Exit code: 1073807364<br>
  </small></blockquote>
<br>
Maybe someone off you can help me:<br>
<br>
Here is the code: Look at line 37: print with_mode(BASIC_CONVERSION,
r.dim)(self._dataFrame)[0]<br>
If I comment this line all work fine ...<br>
But the R function out of the abstrakt GUI function work fine too.<br>
<br>
Regards <br>
Matthias<br>
<br>
---------------------------------------------------------<br>
<br>
import sys<br>
from PyQt4 import QtCore, QtGui<br>
<br>
from rpy import *<br>
<br>
class QagsDataFrameModel(QtCore.QAbstractTableModel):<br>
    def __init__(self, data_frame, parent = None):<br>
        QtCore.QAbstractTableModel.__init__(self, parent)<br>
<br>
        self._dataFrame = data_frame<br>
<br>
    def columnCount(self, parent):<br>
        return 2<br>
<br>
    def data(self, index, role):<br>
        if not index.isValid():<br>
            return QtCore.QVariant()<br>
        if role != QtCore.Qt.DisplayRole:<br>
            return QtCore.QVariant()<br>
        return QtCore.QVariant("2")<br>
<br>
<br>
    def headerData(self, section, orientation, role):<br>
        header_names = ("s", "d")<br>
        if orientation == QtCore.Qt.Horizontal and role ==
QtCore.Qt.DisplayRole:<br>
            if section in range(len(header_names)):<br>
                return QtCore.QVariant(header_names[section])<br>
            else:<br>
                return QtCore.QVariant()<br>
        return QtCore.QVariant()<br>
<br>
    def rowCount(self, parent):<br>
        #<br>
        # Look HERE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br>
        #<br>
        #Here I call an R function:<br>
        print with_mode(BASIC_CONVERSION, r.dim)(self._dataFrame)[0]<br>
        return 3<br>
<br>
<br>
class MainWindow(QtGui.QMainWindow):<br>
    def __init__(self, parent=None):<br>
        QtGui.QMainWindow.__init__(self, parent)<br>
    <br>
        self.fileMenu = self.menuBar().addMenu(self.tr("&amp;File"))<br>
    <br>
        self.fileMenu.addAction(self.tr("E&amp;xit"),
self,QtCore.SLOT("close()"), QtGui.QKeySequence(self.tr("Ctrl+Q")))<br>
    <br>
        df = with_mode(NO_CONVERSION,
r)("data.frame(x=c(1,2,3),y=c(2,3,4))")<br>
        self._model = QagsDataFrameModel(df, self)<br>
    <br>
        self._view = QtGui.QTableView(self)<br>
        self._view.setModel(self._model)<br>
    <br>
        self.setCentralWidget(self._view)<br>
        self.setWindowTitle(self.tr("Simple DataFrame Model"))<br>
<br>
<br>
if __name__ == "__main__":<br>
    app = QtGui.QApplication(sys.argv)<br>
    window = MainWindow()<br>
    window.resize(640, 480)<br>
    window.show()<br>
    sys.exit(app.exec_()) <br>
<FONT SIZE=3><BR>
<BR>
****************************************************************************<BR>
This email and any files transmitted with it are confidential and<BR>
intended solely for the use of the individual or entity to whom they<BR>
are addressed. Access to this e-mail by anyone else is unauthorised.<BR>
If you are not the intended recipient, any disclosure, copying,<BR>
distribution or any action taken or omitted to be taken in reliance on<BR>
it, is prohibited.<BR>
E-mail messages are not necessarily secure.  Renesas does not accept<BR>
responsibility for any changes made to this message after it was sent.<BR>
Please note that this email message has been swept by Renesas for<BR>
the presence of computer viruses.<BR>
****************************************************************************<BR>
</FONT>
</body>
</html>


_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic