<!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>
>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("&File"))<br>
<br>
self.fileMenu.addAction(self.tr("E&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>