[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyKDE] Filling QPixmap from C code
From: "Giaco777" <giaco777 () gmx ! de>
Date: 2003-04-16 7:23:02
[Download RAW message or body]
Hi PyQters,
first of all I would like to thank Phil for this great RAD environment
for QT.
In my application I would like a QPixmap generated by PYQt
to be filled by a C subroutine. My first try would look like this (in principal):
Python:
qp=QPixmap(...)
fillQPixmap(qp) # this is realized in C
C:
// this is the C subroutine which fills QPixmap
static PyObject *fillQPixmap(PyObject *self, PyObject *args) {
PyObject * po;
if(!PyArg_ParseTuple(args, "O", &po)) return NULL;
// interpret object as QPixmap pointer
QPixmap *pm = (QPixmap*) PyCObject_AsVoidPtr(po);
// do something with pm
Py_INCREF(Py_None);
return Py_None;
}
Is there a chance that this will work or is there a better solution?
Thanks
Joachim
[Attachment #3 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi PyQters,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>first of all I would like to thank Phil for this
great RAD environment</FONT></DIV>
<DIV><FONT face=Arial size=2>for QT. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In my application I would like a QPixmap generated
by PYQt</FONT></DIV>
<DIV><FONT face=Arial size=2>to be filled by a C subroutine. My first try would
look like this (in principal):</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Python:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>qp=QPixmap(...)</FONT></DIV>
<DIV><FONT face=Arial size=2>fillQPixmap(qp) # this is
realized in C</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>C:</FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><FONT face=Arial
size=2></FONT></FONT></FONT> </DIV>
<DIV><FONT face=Arial size=2>// this is the C subroutine which fills
QPixmap</FONT></DIV><FONT face=Arial size=2><FONT color=#0000ff size=2>
<DIV><FONT color=#000000>static</FONT></FONT><FONT size=2> PyObject
*fillQPixmap(PyObject *self, PyObject *args) {</DIV>
<DIV> PyObject * po;</DIV>
<DIV></FONT><FONT color=#0000ff size=2> if</FONT><FONT
size=2>(!PyArg_ParseTuple(args, "O", &po)) </FONT><FONT color=#0000ff
size=2>return</FONT><FONT size=2> NULL;</FONT></DIV>
<DIV><FONT size=2> </DIV>
<DIV></FONT><FONT color=#008000 size=2> // interpret object as
QPixmap pointer</FONT><FONT color=#008000 size=2></DIV></FONT><FONT size=2>
<DIV> QPixmap *pm = (QPixmap*) PyCObject_AsVoidPtr(po); </DIV>
<DIV> </DIV>
<DIV> // do something with pm</DIV>
<DIV> </DIV>
<DIV> Py_INCREF(Py_None);</DIV>
<DIV></FONT><FONT color=#0000ff size=2> return</FONT><FONT size=2>
Py_None; </DIV>
<DIV>}</DIV></FONT></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Is there a chance that this will work or is there a
better solution?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2>Joachim</FONT></DIV></BODY></HTML>
_______________________________________________
PyKDE mailing list PyKDE@mats.gmd.de
http://mats.gmd.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