Re: [PyQt] double free issue with OUT-argument

2010-02-19 Thread Diez B. Roggisch

Which version of SIP? I think this is fixed in SIP v4.10.


It in fact is, and upgrading from a 4.9 release candidate or some such 
helped. Thanks.




Unrelated...

There is a memory leak in your %ConvertToTypeCode as PySequence_GetItem()
returns a new reference to the item. However you should use the PyTuple
functions anyway (which don't return a new reference) because you are using
PyArg_ParseTuple() to do the conversion.



Thank you for pointing that out... my wrap-fu isn't to great ;)

diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] double free issue with OUT-argument

2010-02-13 Thread Diez B. Roggisch

Hi,

wrapping happily away a 3D-engine, I encounter the following problem:

 import irrlicht
 core = irrlicht.irr.core
 q = core.quaternion()
 q.toEuler()
python(3701) malloc: *** error for object 0x474b70: double free
*** set a breakpoint in malloc_error_break to debug
(0.0, -0.0, 0.0)


This is the declaration of toEuler in .sip:

  void toEuler(irr::core::vector3df euler /Out/) const;

As you can see, it's supposed to modify a passed vector in place. 
However, I declared vectors to be converted from  to tuples, by this 
code mapping:


%MappedType irr::core::vector3df
{
%TypeHeaderCode
#include vector3d.h
%End

%ConvertFromTypeCode
  if (!sipCpp)
return PyTuple_New(0);
  irr::core::vector3df *v = (irr::core::vector3df *)sipCpp;
  return PyTuple_Pack(3, 
PyFloat_FromDouble(v-X),PyFloat_FromDouble(v-Y),PyFloat_FromDouble(v-Z));

%End

%ConvertToTypeCode
   if (sipIsErr == NULL) {
 if(PySequence_Check(sipPy)  PySequence_Length(sipPy) == 3) {
   for(int j = 0; j  3; j++) {
 PyObject *v = PySequence_GetItem(sipPy, j);
 if(!PyFloat_Check(v)  !PyInt_Check(v)) {
   return false;
 }
   }
   return true;
 }
 return false;
   }
  if (sipPy == Py_None) {
*sipCppPtr = NULL;
return 0;
  }

  irr::core::vector3df *v = new irr::core::vector3df();
  PyErr_Clear();
  irr::core::vector3df t = *v;
  if(PyArg_ParseTuple(sipPy, fff, t.X, t.Y, t.Z)) {
*sipCppPtr = v;
return 1;
  } else {
delete v;
*sipIsErr = 1;
return 0;
  }
%End
};

Looking at the generated code, it seems to me it is perfectly fine - it 
creates a new vector instance, passes that in, converts it to a tuple, 
and deletes it.


extern C {static PyObject *meth_irr_core_quaternion_toEuler(PyObject 
*, PyObject *);}
static PyObject *meth_irr_core_quaternion_toEuler(PyObject *sipSelf, 
PyObject *sipArgs)

{
int sipArgsParsed = 0;

{
irr::core::vector3df * a0;
irr::core::quaternion *sipCpp;

if 
(sipParseArgs(sipArgsParsed,sipArgs,B,sipSelf,sipType_irr_core_quaternion,sipCpp))

{
PyObject *sipResult;
a0 = new irr::core::vector3df();

sipCpp-toEuler(*a0);

sipResult = 
sipConvertFromNewType(a0,sipType_irr_core_vector3df,NULL);

delete a0;

return sipResult;
}
}

/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipArgsParsed,sipName_quaternion,sipName_toEuler);

return NULL;
}


I don't understand the behavior - anything I miss?

Regards,

Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] casting issues

2009-09-16 Thread Diez B. Roggisch

Hi,

when wrapping a C++-library with SIP ( 4.9-snapshot-20090821) I run into 
a couple of issues.


First of all, the library I wrap has a hierarchy of classes (all 
descending from ISceneNode) which I wrapped.


Now through an instance of a so-called ISceneManager, I can access 
instances of the current scene-graph which are ISceneNode-instances. 
Consequently, the signature for one of the accessory-methods looks like 
this:


  ISceneNode *getSceneNodeFromID(int)

So far, so good.

Now problem number one comes up: I *know* a certain node is of type e.g. 
IMeshSceneNode. But when I access it via the above method, all I get is 
an ISceneNode. My C++-foo is rusty, and I know that RTTI isn't always 
available - I just wonder: is there a way for SIP to figure out the 
actual type of the instance returned, and wrap it accordingly? If yes, 
what do I need to do to enable that feature?


However, the library in question offers a getType()-call on ISceneNodes, 
and this I can use to write casting-code myself.


So I tried sip.cast, and that's my second issue for today: this 
dramatically segfaults for me.


What works though is sip.unwrapinstance and sip.wrapinstance called in 
succession. The subsequent tinkering with the nodes shows that it 
actually works.


So the question is - why does sip.cast bomb? I use it like this:

 sip.cast(terrain, scene.IMeshSceneNode)

Regards,

Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] how to wrap anonymous enums

2009-08-31 Thread Diez B. Roggisch

Phil Thompson schrieb:

On Sat, 29 Aug 2009 19:43:24 +0200, Diez B. Roggisch de...@web.de
wrote:

Phil Thompson schrieb:

On Sat, 29 Aug 2009 17:48:11 +0200, Diez B. Roggisch de...@web.de
wrote:

Hi,

I've got a struct like this:

struct SJoystickInfo {
u8  Joystick;
u32 Buttons;
u32 Axes;
enum
{
//! A hat is definitely present.
POV_HAT_PRESENT,

//! A hat is definitely not present.
POV_HAT_ABSENT,

//! The presence or absence of a hat cannot be determined.
POV_HAT_UNKNOWN
} PovHat;
}; // struct SJoystickInfo

So the type of PovHat is an anonymous enum. How to wrap that? I also 
tried to just give PovHat an int-value, but that didn't work either.

It should just work - what problem are you seeing?

A simple syntax eror at the line of PovHat.


Hmm - one for the TODO list.

The workaround is what I think you tried...

enum
{
//! A hat is definitely present.
POV_HAT_PRESENT,

//! A hat is definitely not present.
POV_HAT_ABSENT,

//! The presence or absence of a hat cannot be determined.
POV_HAT_UNKNOWN
};

int PovHat;

...so what problem did you have with that?


This is in my sip-file:

  enum
{
  POV_HAT_PRESENT,
  POV_HAT_ABSENT,
  POV_HAT_UNKNOWN
};

struct SJoystickInfo
{
  irr::u8 Joystick;
  irr::core::stringc Name;
  irr::u32 Buttons;
  irr::u32 Axes;
  int PovHat;
};


This is the compiler error:

sipirrlichtirrSJoystickInfo.cpp: In function ‘int 
varset_irr_SJoystickInfo_PovHat(void*, PyObject*, PyObject*)’:
sipirrlichtirrSJoystickInfo.cpp:215: error: invalid conversion from 
‘int’ to ‘irr::SJoystickInfo::anonymous enum’

error: command 'gcc-4.2' failed with exit status 1


Diez

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] how to wrap anonymous enums

2009-08-29 Thread Diez B. Roggisch

Hi,

I've got a struct like this:

struct SJoystickInfo {
u8  Joystick;
u32 Buttons;
u32 Axes;
enum
{
//! A hat is definitely present.
POV_HAT_PRESENT,

//! A hat is definitely not present.
POV_HAT_ABSENT,

//! The presence or absence of a hat cannot be determined.
POV_HAT_UNKNOWN
} PovHat;
}; // struct SJoystickInfo

So the type of PovHat is an anonymous enum. How to wrap that? I also 
tried to just give PovHat an int-value, but that didn't work either.


Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] how to wrap anonymous enums

2009-08-29 Thread Diez B. Roggisch

Phil Thompson schrieb:

On Sat, 29 Aug 2009 17:48:11 +0200, Diez B. Roggisch de...@web.de
wrote:

Hi,

I've got a struct like this:

struct SJoystickInfo {
u8  Joystick;
u32 Buttons;
u32 Axes;
enum
{
//! A hat is definitely present.
POV_HAT_PRESENT,

//! A hat is definitely not present.
POV_HAT_ABSENT,

//! The presence or absence of a hat cannot be determined.
POV_HAT_UNKNOWN
} PovHat;
}; // struct SJoystickInfo

So the type of PovHat is an anonymous enum. How to wrap that? I also 
tried to just give PovHat an int-value, but that didn't work either.


It should just work - what problem are you seeing?


A simple syntax eror at the line of PovHat.

Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] banging my head on returning short* as void*

2009-08-29 Thread Diez B. Roggisch

Hi,

I'm trying to wrap a method with the following signature:

virtual const u16* getIndices() const

where u16 is typedef'd as simple unsigned short.

Actually, what I'm really just need is a void* here - the indices are 
passed to some other function which takes them as such.


So I tried various things - just giving the above signature makes sip 
fail (understandably) with


sip: irr::scene::SMeshBuffer::getIndices() unsupported function return 
type - provide %MethodCode and a C++ signature
error: command 
'/Library/Frameworks/Python.framework/Versions/2.6/bin/sip' failed with 
exit status 1



So I tried altering the return-type to void*, what made GCC fail with


cc1plus: warning: command line option -Wstrict-prototypes is valid for 
C/ObjC but not for C++
sipirrlichtirrsceneSMeshBuffer.cpp:37: warning: deprecated covariant 
return type for ‘virtual void* sipirr_scene_SMeshBuffer::getVertices() 
const’
../irrlicht-1.5_svn/include/CMeshBuffer.h:47: warning:   overriding 
‘const void* irr::scene::CMeshBufferT::getVertices() const [with T = 
irr::video::S3DVertex]’
sipirrlichtirrsceneSMeshBuffer.cpp:40: error: conflicting return type 
specified for ‘virtual void* sipirr_scene_SMeshBuffer::getIndices() const’
../irrlicht-1.5_svn/include/CMeshBuffer.h:77: error:   overriding ‘const 
irr::u16* irr::scene::CMeshBufferT::getIndices() const [with T = 
irr::video::S3DVertex]’
sipirrlichtirrsceneSMeshBuffer.cpp: In member function ‘virtual void* 
sipirr_scene_SMeshBuffer::getVertices() const’:
sipirrlichtirrsceneSMeshBuffer.cpp:105: error: invalid conversion from 
‘const void*’ to ‘void*’
sipirrlichtirrsceneSMeshBuffer.cpp: In member function ‘virtual void* 
sipirr_scene_SMeshBuffer::getIndices() const’:
sipirrlichtirrsceneSMeshBuffer.cpp:150: error: invalid conversion from 
‘const void*’ to ‘void*’
irr_scene.sip: In function ‘PyObject* 
meth_irr_scene_SMeshBuffer_append(PyObject*, PyObject*)’:
irr_scene.sip:1062: warning: comparison between signed and unsigned 
integer expressions
irr_scene.sip:1065: warning: comparison between signed and unsigned 
integer expressions

error: command 'gcc-4.2' failed with exit status 1



I found sipConvertFromVoidPtr, but don't know how to really use that.

Any suggestions?

Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] sip 4.8.2 error: sip: Unsupported type argument to type2string()

2009-08-28 Thread Diez B. Roggisch

Hi,


as always, your support is plain awesome!

See below for a follow-up-question:

the subject pretty much says it all. I upgraded to the latest SIP 
because I experienced a strange endless-loop-kind of behavior in the 
4.7.* I had before, and now my building bails out with the


  sip: Unsupported type argument to type2string()

error message.

You can find the mercurial repository at

  https://bitbucket.org/deets/irrsinn/

Any ideas?


Two changes in tonight's snapshot...

...to fix the type2string() problem

...to detect recursive class hierarchies - it's now obvious what's causing
your looping.



Great, I've been bitten by that before - but this time there was quite a 
bit of time between altering the source, and trying to compile it again, 
so I forgot.



You also have a couple of syntax errors - forgetting the // around
annotations.



Yep, saw these - it was the first time I was using them anyway, and thus 
 I hadn't the syntax down.


And the reason I started with them is that I have a 
memory-management-issue that is beyond my current understanding.


The library I'm wrapping employs it's own refcounting-scheme. The calls 
grab and drop are used to in- and decrease the refcounter.


Now this leaves me with the problem that

 - when I drop() an object, it get's garbage-collected by C++ - but 
Python keeps a reference, and will of course attempt to de-allocate the 
object again.


 - when I *don't* drop(), and the object is GC'ed by python, there 
should be an implicit drop() called. I don't see a special method 
__del__ which I could use to do that.


So - any suggestions how to tie these two memory-management-systems 
together?


Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] sip 4.8.2 error: sip: Unsupported type argument to type2string()

2009-08-21 Thread Diez B. Roggisch

Hi,

the subject pretty much says it all. I upgraded to the latest SIP 
because I experienced a strange endless-loop-kind of behavior in the 
4.7.* I had before, and now my building bails out with the


 sip: Unsupported type argument to type2string()

error message.

You can find the mercurial repository at

 https://bitbucket.org/deets/irrsinn/

Any ideas?

Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] sipConvertToInstance failing after sipCanConvertToInstance succeeds.

2009-07-22 Thread Diez B. Roggisch

Phil Thompson schrieb:

On Tue, 21 Jul 2009 11:07:19 +0200, Diez B. Roggisch de...@web.de
wrote:

On Tuesday 21 July 2009 10:43:14 Phil Thompson wrote:

On Tue, 21 Jul 2009 09:26:39 +0200, Diez B. Roggisch de...@web.de

wrote:

Hi,

well, the subject pretty much says it. The below code exectutes fine

in

the debugger until it reaches the line

  irr::video::S3DVertex *vertex = (irr::video::S3DVertex
*)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE,
NULL, err);


where err then gets some seemingly random value  the program
terminates. The if-statement below the line doesn't work and was a
feeble attempt at error-handling - a subject that is given not much
more
information in the whole

http://www.riverbankcomputing.com/static/Docs/sip4/c_api.html

page.

Any suggestions? Ah, python is 2.6 on osx, SIP is 4.7.9.


Diez


void append(SIP_PYLIST, SIP_PYLIST);
%MethodCode
   PyObject *py_vertices = a0;
   PyObject *py_indices = a1;
   irr::u32 numVertices = PyList_Size(py_vertices);
   irr::video::S3DVertex *vertices = (irr::video::S3DVertex
*)sipMalloc(sizeof(irr::video::S3DVertex) * numVertices);
   irr::u32 numIndices = PyList_Size(py_indices);
   irr::u16 *indices = (irr::u16*)sipMalloc(sizeof(irr::u16) *
numIndices);

   sipWrapperType *S3DVertexType =
sipFindClass(irr::video::S3DVertex);

   int err;

   for(irr::u32 i=0; i  numVertices; i++) {
PyObject *py_vertex = PyList_GetItem(py_vertices, i);
if(sipCanConvertToInstance(py_vertex, S3DVertexType, SIP_NOT_NONE)) {
  irr::video::S3DVertex *vertex = (irr::video::S3DVertex
*)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE,
NULL, err);
  if(err) {
return -1;
  }
  vertices[i] = *vertex;
} // TODO: raise an exception here!
   }

   for(irr::u32 i=0; i  numIndices; i++) {
PyObject *py_index = PySequence_GetItem(py_indices, i);
irr::u16 indices[3];
for(int j=0; j  3; j++) {
  PyObject *item = PySequence_GetItem(py_index, j);
  if(PyLong_Check(item)) {
indices[j] = (irr::u16)PyLong_AsLong(item);
  } else {
// TODO: raise an exception here!
  }
}
   }
   sipCpp-append((void*)vertices, numVertices, indices,
   numIndices);
   sipFree(indices);
   sipFree(vertices);
%End

What is S3DVertexType? I would expect it to start with 'sipClass_'.

It's a wrapped structure, with the original name irr::video::S3DVertex.



After reading the aforementioned docs, I was under the impression that I
need 
to get a sipTypeDef to check  convert. At least pointers of that kind
are 

taken from sipConvertToInstance and sipCanConvertToInstance.


It needs to be what the documentation calls a generated type object which
all begin with sipClass_ - probably sipClass_irr_video_S3DVertex in this
case.


I did that, without any success - the behavior is the same. I get err 
set to the value 458520, and the program dies with an bus-error/segfault.


Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] sipConvertToInstance failing after sipCanConvertToInstance succeeds.

2009-07-22 Thread Diez B. Roggisch

Phil Thompson schrieb:

On Wed, 22 Jul 2009 20:13:45 +0200, Diez B. Roggisch de...@web.de
wrote:

Phil Thompson schrieb:

On Tue, 21 Jul 2009 11:07:19 +0200, Diez B. Roggisch de...@web.de
wrote:

On Tuesday 21 July 2009 10:43:14 Phil Thompson wrote:

On Tue, 21 Jul 2009 09:26:39 +0200, Diez B. Roggisch de...@web.de

wrote:

Hi,

well, the subject pretty much says it. The below code exectutes fine

in

the debugger until it reaches the line

  irr::video::S3DVertex *vertex = (irr::video::S3DVertex
*)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE,
NULL, err);


where err then gets some seemingly random value  the program
terminates. The if-statement below the line doesn't work and was a
feeble attempt at error-handling - a subject that is given not much
more
information in the whole

http://www.riverbankcomputing.com/static/Docs/sip4/c_api.html

page.

Any suggestions? Ah, python is 2.6 on osx, SIP is 4.7.9.


Diez


void append(SIP_PYLIST, SIP_PYLIST);
%MethodCode
   PyObject *py_vertices = a0;
   PyObject *py_indices = a1;
   irr::u32 numVertices = PyList_Size(py_vertices);
   irr::video::S3DVertex *vertices = (irr::video::S3DVertex
*)sipMalloc(sizeof(irr::video::S3DVertex) * numVertices);
   irr::u32 numIndices = PyList_Size(py_indices);
   irr::u16 *indices = (irr::u16*)sipMalloc(sizeof(irr::u16) *
numIndices);

   sipWrapperType *S3DVertexType =
sipFindClass(irr::video::S3DVertex);

   int err;

   for(irr::u32 i=0; i  numVertices; i++) {
PyObject *py_vertex = PyList_GetItem(py_vertices, i);
if(sipCanConvertToInstance(py_vertex, S3DVertexType, SIP_NOT_NONE))

{

  irr::video::S3DVertex *vertex = (irr::video::S3DVertex
*)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE,
NULL, err);
  if(err) {
return -1;
  }
  vertices[i] = *vertex;
} // TODO: raise an exception here!
   }

   for(irr::u32 i=0; i  numIndices; i++) {
PyObject *py_index = PySequence_GetItem(py_indices, i);
irr::u16 indices[3];
for(int j=0; j  3; j++) {
  PyObject *item = PySequence_GetItem(py_index, j);
  if(PyLong_Check(item)) {
indices[j] = (irr::u16)PyLong_AsLong(item);
  } else {
// TODO: raise an exception here!
  }
}
   }
   sipCpp-append((void*)vertices, numVertices, indices,
   numIndices);
   sipFree(indices);
   sipFree(vertices);
%End

What is S3DVertexType? I would expect it to start with 'sipClass_'.

It's a wrapped structure, with the original name
irr::video::S3DVertex.
After reading the aforementioned docs, I was under the impression that

I
need 
to get a sipTypeDef to check  convert. At least pointers of that kind
are 

taken from sipConvertToInstance and sipCanConvertToInstance.

It needs to be what the documentation calls a generated type object
which
all begin with sipClass_ - probably sipClass_irr_video_S3DVertex in
this
case.
I did that, without any success - the behavior is the same. I get err 
set to the value 458520, and the program dies with an

bus-error/segfault.

I missed your call to sipFindClass().


Ah, ok, I was wondering if sip changed so much. Good to know it didn't, 
but also good to know I can get a static reference  don't need the 
extra call.



It's almost certainly a bug in your handwritten code somewhere - not
necessarily in the code above.


I don't doubt that - I just don't find it... I created some test-code 
that toys around with S3DVertex-objecs, and all works fine. I can 
construct them, I can compare them using their overloaded ==-operator 
,which invokes


sipParseArgs(sipArgsParsed,sipArg,1JA,sipClass_irr_video_S3DVertex,a0)

and that is working. I can access their members, some of them which are 
mapped types.


Do you have any idea how to go about this - can I build SIP in 
debug-mode, and then step into the conversion-code itself? How about 
building the extension in debug-mode - it does have the -g-flag, but 
also a -O3.



Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] sipConvertToInstance failing after sipCanConvertToInstance succeeds.

2009-07-22 Thread Diez B. Roggisch


I missed your call to sipFindClass().

It's almost certainly a bug in your handwritten code somewhere - not
necessarily in the code above.



ok, I'm feeling stupid now. But after building sip with debug enabled, 
and stepping into the conversion-call, I found that the problem was that 
the error-variable I passed was *uninitialized*. There are reasons why I 
don't like c++ anymore...


You mention this behavior in the docs - but maybe an additional warning 
for idiots like me would be in order :)


Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] sipConvertToInstance failing after sipCanConvertToInstance succeeds.

2009-07-21 Thread Diez B. Roggisch

Hi,

well, the subject pretty much says it. The below code exectutes fine in 
the debugger until it reaches the line


	  irr::video::S3DVertex *vertex = (irr::video::S3DVertex 
*)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE, 
NULL, err);



where err then gets some seemingly random value  the program 
terminates. The if-statement below the line doesn't work and was a 
feeble attempt at error-handling - a subject that is given not much more 
information in the whole


http://www.riverbankcomputing.com/static/Docs/sip4/c_api.html

page.

Any suggestions? Ah, python is 2.6 on osx, SIP is 4.7.9.


Diez


void append(SIP_PYLIST, SIP_PYLIST);
%MethodCode
  PyObject *py_vertices = a0;
  PyObject *py_indices = a1;
  irr::u32 numVertices = PyList_Size(py_vertices);
  irr::video::S3DVertex *vertices = (irr::video::S3DVertex 
*)sipMalloc(sizeof(irr::video::S3DVertex) * numVertices);

  irr::u32 numIndices = PyList_Size(py_indices);
  irr::u16 *indices = (irr::u16*)sipMalloc(sizeof(irr::u16) * 
numIndices);


  sipWrapperType *S3DVertexType = 
sipFindClass(irr::video::S3DVertex);


  int err;

  for(irr::u32 i=0; i  numVertices; i++) {
PyObject *py_vertex = PyList_GetItem(py_vertices, i);
if(sipCanConvertToInstance(py_vertex, S3DVertexType, SIP_NOT_NONE)) {
	  irr::video::S3DVertex *vertex = (irr::video::S3DVertex 
*)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE, 
NULL, err);

  if(err) {
return -1;
  }
  vertices[i] = *vertex;
} // TODO: raise an exception here!
  }

  for(irr::u32 i=0; i  numIndices; i++) {
PyObject *py_index = PySequence_GetItem(py_indices, i);
irr::u16 indices[3];
for(int j=0; j  3; j++) {
  PyObject *item = PySequence_GetItem(py_index, j);
  if(PyLong_Check(item)) {
indices[j] = (irr::u16)PyLong_AsLong(item);
  } else {
// TODO: raise an exception here!
  }
}
  }
  sipCpp-append((void*)vertices, numVertices, indices, numIndices);
  sipFree(indices);
  sipFree(vertices);
%End
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] sipConvertToInstance failing after sipCanConvertToInstance succeeds.

2009-07-21 Thread Diez B. Roggisch
On Tuesday 21 July 2009 10:43:14 Phil Thompson wrote:
 On Tue, 21 Jul 2009 09:26:39 +0200, Diez B. Roggisch de...@web.de

 wrote:
  Hi,
 
  well, the subject pretty much says it. The below code exectutes fine in
  the debugger until it reaches the line
 
irr::video::S3DVertex *vertex = (irr::video::S3DVertex
  *)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE,
  NULL, err);
 
 
  where err then gets some seemingly random value  the program
  terminates. The if-statement below the line doesn't work and was a
  feeble attempt at error-handling - a subject that is given not much more
  information in the whole
 
  http://www.riverbankcomputing.com/static/Docs/sip4/c_api.html
 
  page.
 
  Any suggestions? Ah, python is 2.6 on osx, SIP is 4.7.9.
 
 
  Diez
 
 
  void append(SIP_PYLIST, SIP_PYLIST);
  %MethodCode
 PyObject *py_vertices = a0;
 PyObject *py_indices = a1;
 irr::u32 numVertices = PyList_Size(py_vertices);
 irr::video::S3DVertex *vertices = (irr::video::S3DVertex
  *)sipMalloc(sizeof(irr::video::S3DVertex) * numVertices);
 irr::u32 numIndices = PyList_Size(py_indices);
 irr::u16 *indices = (irr::u16*)sipMalloc(sizeof(irr::u16) *
  numIndices);
 
 sipWrapperType *S3DVertexType =
  sipFindClass(irr::video::S3DVertex);
 
 int err;
 
 for(irr::u32 i=0; i  numVertices; i++) {
  PyObject *py_vertex = PyList_GetItem(py_vertices, i);
  if(sipCanConvertToInstance(py_vertex, S3DVertexType, SIP_NOT_NONE)) {
irr::video::S3DVertex *vertex = (irr::video::S3DVertex
  *)sipConvertToInstance(py_vertex, S3DVertexType, NULL, SIP_NOT_NONE,
  NULL, err);
if(err) {
  return -1;
}
vertices[i] = *vertex;
  } // TODO: raise an exception here!
 }
 
 for(irr::u32 i=0; i  numIndices; i++) {
  PyObject *py_index = PySequence_GetItem(py_indices, i);
  irr::u16 indices[3];
  for(int j=0; j  3; j++) {
PyObject *item = PySequence_GetItem(py_index, j);
if(PyLong_Check(item)) {
  indices[j] = (irr::u16)PyLong_AsLong(item);
} else {
  // TODO: raise an exception here!
}
  }
 }
 sipCpp-append((void*)vertices, numVertices, indices, numIndices);
 sipFree(indices);
 sipFree(vertices);
  %End

 What is S3DVertexType? I would expect it to start with 'sipClass_'.

It's a wrapped structure, with the original name irr::video::S3DVertex. 
After reading the aforementioned docs, I was under the impression that I need 
to get a sipTypeDef to check  convert. At least pointers of that kind are 
taken from sipConvertToInstance and sipCanConvertToInstance.

Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] wchar_t type mapping

2009-06-21 Thread Diez B. Roggisch

Diez B. Roggisch schrieb:

Hi,

I want to wrap a method with the following signature:

virtual irr::gui::IGUIStaticText* addStaticText(const wchar_t* text, 
const irr::core::rectirr::s32 rectangle,
  bool border=false, bool wordWrap=true, 
irr::gui::IGUIElement* parent=0, irr::s32 id=-1,

  bool fillBackground = false) = 0;


All types are mapped or declared, and compilation succeeds.

However, on calling the function, Python barks with



Traceback (most recent call last):
  File hello_world.py, line 64, in module
main()
  File hello_world.py, line 45, in main
True);
TypeError: argument 1 of IGUIEnvironment.addStaticText() has an invalid 
type


Ok, I found the problem - one needs to pass a unicode-object. While this 
makes sense to a certain degree, I think it would be good to enhance the 
mapping of wchar_t so that an attempt to convert bytestrings to unicode 
is done (as it is in other python APIs), potentially producing a 
UnicodeDecodeError of course. Would that be something worth considering?


Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] wchar_t type mapping

2009-06-20 Thread Diez B. Roggisch

Hi,

I want to wrap a method with the following signature:

virtual irr::gui::IGUIStaticText* addStaticText(const wchar_t* text, 
const irr::core::rectirr::s32 rectangle,
		  bool border=false, bool wordWrap=true, 
irr::gui::IGUIElement* parent=0, irr::s32 id=-1,

  bool fillBackground = 
false) = 0;


All types are mapped or declared, and compilation succeeds.

However, on calling the function, Python barks with



Traceback (most recent call last):
  File hello_world.py, line 64, in module
main()
  File hello_world.py, line 45, in main
True);
TypeError: argument 1 of IGUIEnvironment.addStaticText() has an invalid type



So I tried to map the wchar_t from and to PyUnicode-objects. But this 
gives me an error that says


mac-dir:IrrSinn-1.5 deets$ python2.6 setup.py install
running install
running build
running build_ext
building 'irrlicht' extension
/Library/Frameworks/Python.framework/Versions/2.6/bin/sip -c 
build/temp.macosx-10.3-i386-2.6 -b 
build/temp.macosx-10.3-i386-2.6/irr.sbf irr.sip

sip: types.sip:613: Invalid type for %MappedType
error: command 
'/Library/Frameworks/Python.framework/Versions/2.6/bin/sip' failed with 
exit status 1



The mapping looks like this:

%MappedType wchar_t*
{
%TypeHeaderCode
#include wchar.h
%End

%ConvertFromTypeCode
  if (!sipCpp)
return Py_None;
  wchar_t *s = (wchar_t*)sipCpp;
  return PyUnicode_FromWideChar(s, wcslen(s));
%End

%ConvertToTypeCode
   if (sipIsErr == NULL) {
 return PyUnicode_Check(sipPy);
   }
  if (sipPy == Py_None) {
*sipCppPtr = NULL;
return 0;
  }
  Py_ssize_t len = PyUnicode_GET_SIZE(sipPy);
  wchar_t *w = malloc(sizeof(wchar_t) * len + 1);
  w[len] = 0;
  PyUnicode_AsWideChar(PyUnicodeObject *unicode, wchar_t *w, Py_ssize_t 
size);

  PyUnicode_AsWideChar(sipPy, w, len);
  *sipCppPtr = w;
  return 1;
%End
};



Any suggestions? Of course if anything else fails, I could manually wrap 
the methods in question - but I'd rather spare myself that effort.


Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Problems with stylesheets.

2007-12-05 Thread Diez B. Roggisch
On Tuesday 04 December 2007 13:04:12 Gustavo A. Díaz wrote:
 I will say for a last time... for a stylesheet is not needed... one could
 create a simple widget to test the stylesheet, and instead of images to use
 just colors. Is in vain to post a code for this and, i already posted
 the stylesheet code. If was pure code, i agree... but is not this case...
 so please...

To quote from your solution post:


Was cause for example i was styling the scroll bar which was inside a
textEdit using self.stylesheet(QScrollbar bla bla bla) so to style all the
scrollbars of the app, but, i already had self.stylesheet(QPushButton bla
bla) in my app, so when i was styling the scrollbar, i was disabling the
QPushButton style.


So  - what mattered - amongst the stylesheet - were 

 - arrangement of widgets

 - methods used

Which is exactly the reason Hans-Peter  Doug asked for a self-contained 
example.

Now how does that compare to your above assertions that 

' for a stylesheet is not needed... one could create a simple widget to test 
the stylesheet, and instead of images to use just colors. Is in vain to post 
a code for this...

You should think about your attitude.

Diez

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] optimization

2007-12-03 Thread Diez B. Roggisch

Linos schrieb:

hello,
i would like to know if exist any link about specific optimization tips 
for python using pyqt i am trying to
optimize the code the most possible to try to maintain in pyqt and not have to 
reprogram in c++, for example
do have psyco good results?


What optimization are you talking about? Psyco is about optimization of 
numeric calculations. (Py)Qt has nothing to do with that. And you can 
use them together, yes.


GUI-code as such is seldomly in need for optimization. With the 
exception of e.g. real time graphics for games or scientific visualization.


Regardless of what you actually need - don't optimize prematurely. Just 
code correct code - then profile it to see where it lacks performance.



Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] property support?

2007-08-17 Thread Diez B. Roggisch

Hi,

is there any existing or planned property-support? I've got a class that 
essentially looks like this:


class Foo {
public:
   SomeType Name[Size];
};


So the Name-property is part of the public API. I'd like to access that 
using


foo_instance.Name

instead of introducing a getter/setter-pair. Any suggestions?

Regards,

diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] property support?

2007-08-17 Thread Diez B. Roggisch

Phil Thompson schrieb:

On Friday 17 August 2007, Diez B. Roggisch wrote:

Hi,

is there any existing or planned property-support? I've got a class that
essentially looks like this:

class Foo {
public:
SomeType Name[Size];
};


So the Name-property is part of the public API. I'd like to access that
using

foo_instance.Name

instead of introducing a getter/setter-pair. Any suggestions?


http://www.riverbankcomputing.com/Docs/sip4/sipref.html#getcode


Great. I searched the docs for property, but that wasn't mentioned 
around %GetCode/%SetCode.


However utilizing it, I stumbled over the following error:

sip: irr::video::SMaterial::TextureWrap has an unsupported type


The declaration looks like this (for now I don't care about setting, but 
I stubbed it to make sure that's not the problem cause)


  //! Texture Clamp Mode
  irr::video::E_TEXTURE_CLAMP *TextureWrap;
%GetCode
if(sipCpp  *sipCpp) {
  sipPy = PyTuple_New(MATERIAL_MAX_TEXTURES);
  irr::video::E_TEXTURE_CLAMP *tw = *(irr::video::E_TEXTURE_CLAMP 
**)sipCpp;

  const enumType *sipFindMappedType(irr::video::E_TEXTURE_CLAMP);
  for(int i = 0; i  MATERIAL_MAX_TEXTURES; i++) {
PyTuple_SetItem(sipPy, sipConvertFromNamedEnum(tw[i], enumType));
  }
 } else {
  sipPy = Py_None;
 }
%End
%SetCode
sipCpp = 0;
%End


E_TEXTUR_CLAMP is your run-off-the-mill enumeration type. Any 
suggestions why that fails?


Regard,s

Diez
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] problem with abstract classes

2007-08-14 Thread Diez B. Roggisch

Giovanni Bajo schrieb:

On 12/08/2007 16.20, Diez B. Roggisch wrote:

Any suggestions? Am I doing something fundamentally wrong wrt 
implementation of C++-interfaces?


Please post a minimal, complete example that reproduces your problem. 
Otherwise, it's a little hard to help you...


I know... So I tried to come up with a smaller example. However, it's 
not showing the same, but another problem. Until that is fixed, I think 
investigating the old problem is pretty much useless.


The attached project tries to model the situation I have in my real app. 
It compiles  runs under my Mac.


Essentially all I try to do is to create a interface in C++ 
(IEventReceiver), a subclass (PyIEventReceiver) to overload the pure 
virtual methods of the base-interface so it can be overloaded in python 
and a test-class that invokes the OnEvent-method in a previously set 
IEventReceiver implementation.


Then in the python-test-script, I try and instantiate the test-object, 
and subclass the PyIEventReceiver. The latter is the problem. When 
passing that into the test-object and invoke the test-method, I don't 
get the overloaded method invoked.


How do I achieve that?

I'm not sure if the two problems are related - but until this works, 
it's moot to try and make the other problem go away.


Kind regards,

Diez


SIPTest.tgz
Description: GNU Zip compressed data
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] problem with abstract classes

2007-08-12 Thread Diez B. Roggisch

Hi,

I'm in the process of wrapping the irrlicht 3d engine. So far, things 
have been working smoothly. However, now I stumbled over a problem that 
so far has not been willing to be disappearing, intensive gdb-use 
notwithstanding.


There is a pure abstract class in Irrlicht, IEventReceiver. It looks 
like this:


//! Interface of an object which can receive events.
class IEventReceiver
{
public:

virtual ~IEventReceiver() {};

//! called if an event happened. returns true if event was processed
virtual bool OnEvent(SEvent event) = 0;
};

This class I wrapped in SIP this way:

   class IEventReceiver /Abstract/ {
%TypeHeaderCode
#include IEventReceiver.h
%End
   public:
 bool OnEvent(irr::SEvent event);
   };


Which seems to work fine. Now of course I'm having troubles subclassing 
this class in Python, which is the reason I created a dummy-implemntation


namespace irr {
  class PyIEventReceiver : public IEventReceiver {
  public:
virtual ~PyIEventReceiver();
bool OnEvent(SEvent event);
  };
};

It is declared in my SIP-file as this:

   class PyIEventReceiver : irr::IEventReceiver {


   public:
 bool OnEvent(irr::SEvent event);
   };

I can subclass this class in python, and my SEvent-marshalling-code 
works fine as well, as the following test-script shows:


class MyER(irrlicht.irr.PyIEventReceiver):
def OnEvent(self, event):
print event

er = MyER()

event = (irrlicht.irr.EET_MOUSE_INPUT_EVENT, 100, 100, .5, 1)
er.OnEvent(event)



But now if I set this IEventReceiver to my IrrlichtDevice, I get the 
following error (inside GDB):


Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0008
0x0297119f in irr::CIrrDeviceStub::postEventFromUser (this=0x141a8f0, 
event={EventType = EET_MOUSE_INPUT_EVENT, {GUIEvent = {Caller = 0x145, 
EventType = 247}, MouseInput = {X = 325, Y = 247, Wheel = 0, Event = 
EMIE_MOUSE_MOVED}, KeyInput = {Char = 325, Key = KEY_CRSEL, PressedDown 
= false, Shift = false, Control = false}, LogEvent = {Text = 0x145 
Address 0x145 out of bounds, Level = 247}, UserEvent = {UserData1 = 
325, UserData2 = 247, UserData3 = 0}}}) at 
/Users/deets/Download/irrlicht-1.3.1/source/Irrlicht/MacOSX/../CIrrDeviceStub.cpp:164

164 absorbed = UserReceiver-OnEvent(event);
(gdb) p UserReceiver
warning: RTTI symbol not found for class 'irr::NSOpenGLViewDeviceDelegate'
$1 = (IEventReceiver *) 0x1492ec0
Current language:  auto; currently c++

UserReceiver here is a pointer to a IEventReceiver, which seems to be 
correctly set. I tried stepping into the code, but wasn't able to.


This is with OSX 10.4, Python2.5, latest stable sip (4.7).

Any suggestions? Am I doing something fundamentally wrong wrt 
implementation of C++-interfaces?


Kind regards,

Diez

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyKDE] Problem with Eric3

2006-03-20 Thread Diez B. Roggisch
On Monday 20 March 2006 09:43, TAC-TAC computer s.r.o. wrote:
 Don't worry, it will never work!
 I have exactly the same problem.
 Still waiting for help (rather working with wxwidgets  boa now) :-)

It works perfectly under Linux - but I had the same problem under Windows. 
Which is most probably because eric doesn't find the executables. You _could_ 
try and debug that and contribute that back to the community. But I certainly 
won't lure you away from wx...

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Debugging a segfault in Linux

2006-03-17 Thread Diez B. Roggisch
On Friday 17 March 2006 15:27, Mike Tammerman wrote:
 Hi,

 I'm trying to implement a distributed media player using twisted and
 pyqt. Sometimes, I am getting segfaults for the gui part. I am using
 custom widgets and I don't know if the reason of the problem is myself
 or pyqt or something else.

 I want to learn how to debug pyqt apps. Is there a practical way
 you're using? I am using ubuntu(breezy) and its pre-compiled packages.

You'll need debug-builds of whatever you can get one for - so most probably 
you should build every piece of the toolchain with debug information enabled.

Luckily you're on a debian-based system. That means that you can get the 
source-packages easily (apt-source or apt-get source). Fetch them with all 
dependencies. Then you can build the packages yourself - check out the 
package/debian/rules, ususally there are the configure-statements. Build 
with e.g. 

fakeroot debian/rules binary

Then install the packages.
When everything is set up, you can debug things using the gdb - just pass e.g. 
python as execuatbe like this

gdb python

gdb set args yourscript
gdb run


That all ist just a rough sketch, atop of my head. But it should give you some 
pointesr I hope.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Debugging a segfault in Linux

2006-03-17 Thread Diez B. Roggisch
 Program received signal SIGSEGV, Segmentation fault.
 [Switching to Thread -1209734944 (LWP 16726)]
 0xb7682318 in QObject::parent (this=0x) at qobject.h:154

This looks fishy - a this with value -1 ist most probably an uninitialized 
pointer. Try investigating that.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] also about pyqt

2006-03-14 Thread Diez B. Roggisch
 dist/hello
 dist/pcre.so
 dist/pwdmodule.so
 dist/strop.so

 please explain how to build an rpm-package from that files

I've got debian, I don't need no RPM. 

The purpose of cx is to create a distribution-independent format, by bundling 
executables and libs and the like. It is _not_ there to create RPMs or other 
distribution-dependend installation files. Because that wouldn't make much 
sense - I for example can install the whole PyQt stuff with a simple

apt-get install pyqt

so I don't need a debian package containing all that stuff again. Instead, I 
need a debian package that has the proper dependencies set. The same is true 
for RPM-based systems.

And besides: this is the pyQt mailing list. While I doubt that someone will 
object you asking cxFreeze-questions here, you most likely will get better 
help on cxFreeze own mailing list.

DIez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Using PIL in PyQT

2005-11-26 Thread Diez B. Roggisch

Rajeev Joseph Sebastian wrote:

Hello all,

Is it possible to load images using PIL and draw them on screen using PyQt ? 
Does anyone have any code snippet that could make this possible ?


Certainly. Qt supports some powerful formats, e.g. PNG. So open a image 
with PIL, and serialize it to memory using cStringIO as a PNG. The load 
it as QImage from there, providing the data as binary string by the 
means of a QByteArray. Module struct or ctypes might come in handy here.


Other data formats may be even better - try whatever suits you best.

However I don't have code - but I guess you get the gist.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] python from qt import *

2005-11-23 Thread Diez B. Roggisch
On Wednesday 23 November 2005 18:39, Peter Wasenda wrote:
 i get this error ?
 ImportError: /usr/lib/python2.4/site-packages/qt.so: undefined symbol:
 sipType_QInputDialog

Which OS, which pyqt version, installed from where (package manager vs. 
source), if the latter what did you pass to configure the modules?

http://www.catb.org/~esr/faqs/smart-questions.html


Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PyKDE + KAddressBook API?

2005-11-03 Thread Diez B. Roggisch
Am Donnerstag, 3. November 2005 14:19 schrieb Gustavo Sverzut Barbieri:
 Hello,

 There is any way to use kabc
 (http://developer.kde.org/documentation/library/3.4-api/kabc/html/index.htm
l) from within Python?

I once wrote a wrapping for it  a few month ago. If I get back to my linux 
machine I can give it to you.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Sql prepare

2005-11-03 Thread Diez B. Roggisch

Matthias Frick wrote:

hi i got some problems with the prepare function fo QSqlQuery

i dont get some usefull back.

here my code:

print db
query = QSqlQuery(db)
print query.prepare( Select :l, lot_id from yb_lot_history where rownum 
 4 )

print query.bindValue( :l, QVariant(lot_id), QSql.ParameterType(3))
print query.execQuery()
print query.isActive()
print query.executedQuery ()

while query.next():
   print erg:,query.value(0).toString()


and here the output:

qtsql.QSqlDatabase object at 0x009C8B70
True
None
True
True
Select :l, lot_id from yb_lot_history where rownum  4
erg: lot_id
erg: lot_id
erg: lot_id


That won't work, as binding parameters fills in the _value_ of that 
parameter. So it is equivalent to


select 'lot_id', lot_id from 

I fear you can't do what you want - you have to create the sql statement 
directly with strings:


select  + column_name +  from ...


Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] unicode two-way conversion

2005-10-25 Thread Diez B. Roggisch
 Ah, that helps the problem in my test script. Now I'm encountering a
 problem encoding the input of a QLineedit:

   File john.py, line 154, in dataFromGuiToUser
 self.user.data[achternaam] = self.GAchternaam.text().encode('utf-8',
 'strict')
 AttributeError: encode

text() returns a QString, which you should look up in the qt-reference-manual. 
That reveals the method

QString::utf8()

which returns a QCString. And that should be converted to a python byte string 
(by means of sip I think)

Then you need to _decode_ it as utf-8 to yield a unicode object. So the whole 
line should read

self.user.data[achternaam] = self.GAchternaam.text().utf8().decode('utf-8')

Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] QString in PyQt4 - Request for Comments

2005-10-21 Thread Diez B. Roggisch
 I disagree with Giovanni.  I signal signatures could be made somewhat
 more pythonic without the adverse impact.  For example, it could remove
 the C++ constant, pointer and reference indicators (const, * and
 ) that Python-only programmers don't really understand.  As long as
 the change was consistent, you would not need to use a second manual.
 And it would make it easier to remember some signatures without referring
 to a manual or wondering whether the parameter was a constant, pointer
 or reference.

If the change could be made whilst supporting the old fully qualified 
format, I'm all for it.

 Regarding the more general questions, I also think that things should be
 made a bit more pythonic without deviating much from the Qt API.
 Python unicode strings should be returned in place of QString, maybe
 with a way of using a switch to get the QString if desired.  And I think
 that Python containers should be used in place of Qt's template
 containers.

These two points I totally support - QString has bitten me more than once, and 
using the template classes appears somewhat archaic to me - especially 
because python is so strong and neatly integrated in the field of iterators 
and so on.

Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PyQT Threading on Windows?

2005-09-01 Thread Diez B. Roggisch

I assume from what you say that you are using the non-commercial version
of Qt/PyQt on Windows. This is SIP v3 based because the version of Qt is
v2.x. If you want a version built with SIP v4 you will need the commercial
versions of Qt and PyQt.


He says Qt 3.x - so I guess he might be using Qt-free-win edition? I had 
similar problems there - QCustomEvent for inserting concurrent events 
into the event-loop of qt didn't work. Never tried to tackle that, 
though - with qt4 on the horizon.



Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] latest eric3 snapshot rocks!

2005-08-23 Thread Diez B. Roggisch
Hi,

just got around testing the latest snapshot - great! The toolbar-search is 
close to what I always dreamt of. Only a few  questions arose:

 - it's a combo-box - but for me, it doesn't do anything.
 - is it possible to bind the incremental search to some key?
 - same for search next/prev incremental.

 I looked in the shortcuts, but no luck. Maybe I missed it - it's pretty 
crowded in there by now. 

And some semantics of the emacs incremental search I really like, so maybe 
they are feasible, too:

1) If one presses C-s, the minibuffer opens, and one can start typing. The 
equivalent here would be that the first press would put the focus into the 
search field

2) if C-s is pressed again while in the minibuffer, the search next 
functionality is executed - thus, no shortcut is wasted. So if the focus is 
in the search field, pressing the same shortcut would search again.

3) Pressing C-w while searching will expand the search term to the 
word-boundary the cursor is currently over. I better explain this by example:

Let's say you have a few methods called show_*, where * is of course 
something like tables or images or whatever. Now when I want to find one 
of these, e.g. show_tables, I type C-s, then type show_. I then repeat 
pressing C-s. Of course all strings containing show_ are found. Now when the 
cursor is positioned over something like

self.show_^tables 

with ^ indicating the cursor position.

I can press C-w, which will expand the search term to the next word boundary - 
in this case show_tables. So I only search for that subsequently.

4) Pressing C-s twice when not in the minibuffer (or, so to speak, once again 
with an empty buffer, as the first puts the focus there) will reuse the last 
search term.

I don't know if and which of these things is easy to implement - I guess 
having at least the possibility of shortcuts for search next/prev shouldn't 
be too hard. All other stuff is just a suggestion.

All in all, it's always impressing at which speed eric evolves and how useful 
for me it becomes - so far it's the only IDE that lured me away from XEmacs, 
and that includes TogetherJ and Eclipse as failing competitors...

Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] pyQT tutorial _downloadable_

2005-08-07 Thread Diez B. Roggisch

Rakotomandimby (R12y) Mihamina wrote:

Hi,

I found this as pyQT tutorial:
http://www.opendocspublishing.com/pyqt/

Well... I found no way to download it, I need to have it in an electronic form 
(PDF, HTML,...).


My notebook is not always connected to the Net, and, having a paper book would 
be too much heavy, and eating space... would you know any PDF version of it? 



wget?

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] [eric3] file/class browser

2005-07-17 Thread Diez B. Roggisch
How should the editor know, which class a variable belongs to. Python is a 
dynamically typed language. This means, that the type of an object is 
determined at runtime. This is a very big difference to C++ or Java, where a 
scanner can parse the source and determine the type of an object even before 
the code is compiled. 


I'm pretty well aware of that - but I'm talking about visiting a file 
via the tabs, detecting code in it like


self.foobar()

and then one wants to visit foobar - which is located in the same file. 
So syncing the classbrowser with the currently visited file is nice. No 
reflection/type inference here.



Somebody recommended to make a toolbar with an entry for the search expression 
and a find and find next button. The search should use the flags set last 
time the search dialog was used. How about that?


The important part for me would be that it's fully Key-operated - in 
emacs, I press C-s for forward search, then start typing which does 
incrementally search. Pressing C-c twice makes the last search 
expression appear. C-r does the same backwards.


Displaying the search term in a toolbar is ok, but the advantage of the 
minibuffer-style is that it occupies precious screenspace only when needed.






And the ability to search forward/backward from the current cursor
position with possible wrap arounds instead of always beginning at the
top would also be great. Any chances for this?



That is in. Just select the backwards checkbox and select Find Again (or press 
F3).


It's not about searching backward, but about searching from the cursor 
position - instead of the beginnig, which is AFAIK the eric behaviour 
.I'm on my mac now and haven't eric running, so I can't check that out - 
but I was annoyed by that, and usually I know how to operate GUIs so I'd 
seen an option that changes that behaviour - I hope at least.



Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] where is logconf.py?

2005-07-12 Thread Diez B. Roggisch

Paul Elliott wrote:

Hello, I am trying to learn python and eric, so I will
probably be asking some dumb questions for a while


I am trying to figure out logging. In

http://www.red-dove.com/python_logging.html

it refers to something called the GUI configurator, logconf.py.

But I can not find it in my 2.4 python distribution, even
though it has logging.config.


You can download it from the very site you cite - it's a proprietary 
piece of software, not in the standard lib.


Generally this list is not well suited for such questions, as it's 
dedicated to the usage of pyqt, pykde and maybe eric - but there is the 
python tutor list, the python list and the comp.lang.python NG (which is 
mirrored to the python ML) for you to ask questions.


http://mail.python.org/mailman/listinfo/tutor
http://mail.python.org/mailman/listinfo/python-list

regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] [eric3] file/class browser

2005-07-12 Thread Diez B. Roggisch



That could be added. What would it be good for?


It's sometimes nice in larger projects when you browse a file that e.g. 
contains a class which has a method foo, which in turn calls a bar 
method in that very class. Then you can simply use the object browser to 
jump there instead of skimming through the file.


BTW, a feature that I'm personally missing most in all not 
emacs/vi-flavoured editors is an incremental search with a 
minibuffer-style search dialog.The reason is simply that the rather 
large search dialog obstructs the editor view.


And the ability to search forward/backward from the current cursor 
position with possible wrap arounds instead of always beginning at the 
top would also be great. Any chances for this?


Thanks,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Wiki logo

2005-07-03 Thread Diez B. Roggisch

Torsten Marek wrote:

Hi all,

I convinced my girlfriend that making a logo for the PyQt wiki is good use for
her creativity; and here is the result. Anybody doesn't like it? Otherwise I'll
set it up as the logo tomorrow.


I like it.


Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] eric3 - unfold class fields

2005-06-28 Thread Diez B. Roggisch
Am Sunday, 26. June 2005 16:03 schrieb alex rait:
 At last I managed to install eric3 and it works ok.

 Now I have some question about the editor - Is there a way to unfold the
 class fields(methods, instance variables) when I enter . for instance?
 This is the way I do it in Eclipse with java or visual studio/kdevelop with
 c++. The only thing I could find so far is the autocomplete feature, but it
 is not what I want...

 Is there any solution to it?

No. This is generally not doable for a dynamic typed language like python. Of 
course if you'd use eric for C/Java development, one could make this work - 
but that would be a major effort. 

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PyQt and sip: WId is undefined

2005-06-21 Thread Diez B. Roggisch
 I don't know PyQt myself (as I am helping with packaging), but we hope to
 have a consistent environment from Darwin, Mac OS X, Solaris, and NetBSD
 (which all have X). But maybe the PyQt-mac for Mac OS X will behave the
 same.

What are your worries? I use PyQt on mac - and it doesn't require me to run 
X11, which I as a user think is very good. And there is no os-specific stuff 
in my apps to do (at least not regarding qt itself). 

The whole purpose of Qt is to behave the same - regardless of the platform. 
That's why it's called platform independed.. :)

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Custom signal/slot function

2005-06-19 Thread Diez B. Roggisch

Kevin Walzer wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I'm working on my first PyQt application, and to get a feel for signals
and slots, I'm trying to have my application echo the text entered into
a line edit widget to stdout. However, when I test this, what is printed
is Not implemented yet, which tells me I'm doing something wrong.

Here is my ui.h code:

void form1::LaunchFoo()
{
~  # get the text typed in the line edit
~  e = self.lineEdit1.text().ascii()

~   #show output
~os.system('echo %s', e)
~}


I've also tried the simple statement print %s, e, but I also get the
not implemented yet error.

Can anyone help point me in the right direction?


The ui.h file is of no use here AFAIK. What you do is to subclass your 
generated widget class and then override the slot method - that's all.


Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Re: [Eric] How to use ipython ?

2005-06-01 Thread Diez B. Roggisch

 Actually the IPython feature I'm the most missing, if not the only one, is
 completion. This is a valuable improvement over the standard python
 interpreter, when in the implementation/testing phase ; that's why it made
 sense to me to have IPython run inside a python IDE...

My eric has tab-completion working in it's interpreter already - in form of a 
window popping up giving me the possible choices. Which is nice, but could 
IMHO enhanced a great deal by implementing in incrementally, like the 
autocompletion in scintill. Any chances we see that coming, Detlev?

Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PyQt Applet on Mac

2005-05-28 Thread Diez B. Roggisch
I have to admit that all the (mac)python is somewhat confusing to an old 
linux guy like me - in fact I even have a third lib dir, the usual 
/usr/lib/python2.3/... where my self-compiled extensions like omniorb live.


Ok, so I digged somewhat more and found that /System/Library is the 
preinstalled version, where /Library is the MacPython verision - which 
is used by the IDE. S - is there a way to make pyqt use the 
macpython version?

Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PythonQt for Windows

2005-04-29 Thread Diez B. Roggisch
 I used mingw but had no problems with it so far. What binary extensions
 are we talking about here?

win32. The exe installers want a normal python, and I didn't make it compile 
using mingw. As win32 is pretty important on windows I'd love to see it 
working.


Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PythonQt for Windows

2005-04-29 Thread Diez B. Roggisch
 I have compiled qt,sip,qscintilla and pyqt with mingw. I have used a
 standard python-2.4.1.msi downloaded from python.org 

You did use a standard python and did not build it yourself? Hrmph. I was 
under the impression that I needed to do that  - but I had troubles with a to 
recent mingw version too, so maybe that caused trouble that in the end made 
me believe that I had to compile all myself.

I think I go and start using your package :)

 so I think you 
 should have no problem adding win32 (is that the one from mr. Hammond?)
 to this. If that is working maybe you can give me a URL so I can add
 that installation to this collection/build.

Yes, m hammonds. It should be this link:

http://prdownloads.sourceforge.net/pywin32/pywin32-204.win32-py2.4.exe?download

If you include that too it would be great - after all, AFAIK activestate's 
python distribution also does exactly that - coding under windows makes it a 
sort of a obligatory extension. 

Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PythonQt for Windows

2005-04-28 Thread Diez B. Roggisch
Hi,

 Qt, Python and Eric3 fans. I have prepared an all in one Windows
 executable and would like to have some feedback/bugreports.
 I have used the GPL version of all software!
 The installer can be found on http://pythonqt.vanrietpaap.nl

 This URL might change in the future if bandwidth is insufficient!

What compiler did you use? I used mingw - which causes me trouble with binary 
extensions not compiling. So if you used the MSVC, I'd certainly be 
interested in using your package.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Render widgets to canvas/buffer

2005-04-22 Thread Diez B. Roggisch
Hi,

this is more of a Qt-question I believe, but I'll ask here anyway - maybe 
someone on this list has done it before. And google didn't help me so far.

I'm looking for a way to draw my widgets to a canvas so that I can create 
snapshots of my widgets.

The overall goal is to create a toolchain so that I can update my applications 
docs with the real widgets instead of hand-made snapshots that are 
automatically outdating.

Any suggestions?

Regards,

Diez B. Roggisch

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Render widgets to canvas/buffer

2005-04-22 Thread Diez B. Roggisch
Am Friday, 22. April 2005 15:00 schrieb Diez B. Roggisch:
 Hi,

 this is more of a Qt-question I believe, but I'll ask here anyway - maybe
 someone on this list has done it before. And google didn't help me so far.

 I'm looking for a way to draw my widgets to a canvas so that I can create
 snapshots of my widgets.

 The overall goal is to create a toolchain so that I can update my
 applications docs with the real widgets instead of hand-made snapshots that
 are automatically outdating.

 Any suggestions?

Just for the record: It's QPixmap.grabWidget() that does the trick. Neat.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] QMessageBox, avoiding virtual desktop switching

2005-04-08 Thread Diez B. Roggisch
Am Freitag, 8. April 2005 20:38 schrieb Alfred Young:
 I'm having a bit of trouble here, I've got a Qt prog that runs in the
 background and I consistently work in other desktops.

 However, when QMessageBox shows, the virtual desktop automatically
 switches to the originating desktop.  Is there a way to prevent this
 from happening?

That certainly is a behaviour created by your windowmanager - which one do you 
use? I e.g. use KDE, and new windows are communicated by flashing their tag 
in the windowlist in my panel. So go and try to reconfigure your WM.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] pyuic doesn't import kde modules

2005-04-07 Thread Diez B. Roggisch
 As $subject says, pyuic does not seem to be aware of the fact that kde
 modules are needed when compiling .ui files that are using KDE widgets. To
 reproduce it:
snip
 I came across this when designing a GUI (d'oh!), as soon as I added the
 first KDE widget, I had to manually add the missing includes before I was
 able to test. Did I miss something?

In qt-designer you can add a form-comment that starts with Python: - all that 
follows will be copied literally into the generated source. So that's the 
place to put import kde statements. No idea how that works with kdevdesigner, 
didn't use it. But if its based on qt-designer, it will work.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Eric3 Usability Questions / Feedback

2005-03-18 Thread Diez B. Roggisch
 That could be done. Right now, directories don't have a context menu.
 Maybe, you can specify the entries, a context menu for directories should
 have in the various project browser.

I'll look into that, hopefully this weekend.

 You are right. I just checked the Qt documentation and that is, what it
 should do. Unfortunately, I cannot see a reason, why the toolbars aren't
 shown in the context menu. Maybe you spot something.

Hm. My own app doesn't make much use of toolbars so far, so I don't have 
expirience so far. But I'll see what happens to me if I try to extend my 
toolbars.

 The default file extension for the open dialog is determined by the
 extension of the current editor. That means, if the current editor is a
 Python file, *.py is selected, if it is an IDL file, *.idl is selected and
 so on.

Good to know .

 What do you mean by outline view?

The class/functions overview like in python-mode.

Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Eric3 Usability Questions / Feedback

2005-03-18 Thread Diez B. Roggisch
 The default file extension for the open dialog is determined by the
 extension of the current editor. That means, if the current editor is a
 Python file, *.py is selected, if it is an IDL file, *.idl is selected and
 so on.

Just checked: That doesn't work for other files. I opened a yaml-Document 
and the default extension seems to be python. 

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Eric3 Usability Questions / Feedback

2005-03-18 Thread Diez B. Roggisch
 That only works for extensions eric3 knows about. Yaml isn't among them.

Sure - so just make the unknown files default extension in the filedialog  
.* :)

Regards, 

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Eric3 Usability Questions / Feedback

2005-03-16 Thread Diez B. Roggisch
 It would be cool if the first context menu action would ask for the
 filename (the destination is known by the context the context menu is
 created in :), create a template and then one would just need to save the
 file in the designer.

My bad, I just used that feature and it already works the way I want - so I 
apologize to you, Detlev. When writing that post I hadn't eric running to 
try.

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Eric3 Usability Questions / Feedback

2005-03-15 Thread Diez B. Roggisch
 1. I create a new project and want to add a .ui form. What's the easiest
 way to do this?

 2. What's the easiest way to create a new Python script and add it to the
 current project?

 3. Is there any way to remove some of the toolbars? I can undock them, but
 can't seem to get rid of them.

I second all these remarks on the usability - they are my concerns too. 

However I can see that point 1 is more complicated than it may seem, as 
creating a ui file most certainly needs some initial setup like base-class 
and name and so on, so that a dialog for that will resemble more or less the 
qt-designer new-ui file dialog/wizard. Which shouldn't be too complicated for 
simpler widgets, but the more elaborate wizards certainly take effort to 
reproduce whilst having limited benefit (its not too often that one creates 
an ui file compared to editing it)

Regards,

Diez

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Binding parameters to slots

2004-12-16 Thread Diez B. Roggisch
Am Donnerstag, 16. Dezember 2004 16:01 schrieb Jeremy Sanders:
 Hi -

 I'm trying to connect a signal in my class to a signal, but bind one of
 its parameters to the signalling object:

 For instance, I want to do something like

 self.connect( button, qt.SIGNAL('clicked()'),
lambda button=button: sys.stdout.write(button) )

 or

 self.connect( button, qt.SIGNAL('clicked()'),
lambda button=button, self=self: self.slotTest(button) )

 None of the options I've tried seem to work. Is this possible??

As I learned from Phil two days ago, for your case there exists

self.sender()

that you can call to get the source of your signal.

Before I knew that, I suggested this solution:

class Magic(QObject):
 def __init__(self, dialog, key):
QObject.__init__(self)
self.dialog = dialog
self.key = key

def focusLost(self):
  self.dialog.keyLostFocus(self.key)


magic = Magic(self, key).focusLost
self.connect(key, SIGNAL(focusLost()), magic)
self.magics.append(magic)

That should allow you to pass arbitrary parameters to to magic, that you then 
in return can invoke your slot with.

Unfortunately, you have to keep a reference to magic-objects as otherwise the 
GC will hit, and the connection is lost. Found that just yesterday - one 
never stops to learn.

Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] QThread

2004-12-14 Thread Diez B. Roggisch
Hi,

right after finishing my work on a make-shift 
process-spawning-and-killing-framework to have concurrent threads that can be 
terminated to circumvene the lack of such a feature in the python threading 
model, I discovered QThread. Now I wonder if my work is totally obsolete, or 
if there are any pitfalls regarding QThread that render it unwise to use 
them. Any comments?

Regards,

Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] QThread

2004-12-14 Thread Diez B. Roggisch
 right after finishing my work on a make-shift
 process-spawning-and-killing-framework to have concurrent threads that can
 be terminated to circumvene the lack of such a feature in the python
 threading model, I discovered QThread. Now I wonder if my work is totally
 obsolete, or if there are any pitfalls regarding QThread that render it
 unwise to use them. Any comments?

To answer my own question: At least together with omniorb, things don't work 
out so well - killing the thread while a corba-request is pending kills the 
whole application. So my work has not been for the dustbin...

Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Static member functions

2004-12-13 Thread Diez B. Roggisch
Hi,

I think I understand your problem as follows: You have a non-parametrized 
signal, lostFocus, that you want to connect to one slot - but then somehow 
magically there shall be a reference to the object the signal came from is 
passed.

May be what could help is somthing like this:

class Magic(QObject):
 def __init__(self, dialog, key):
QObject.__init__(self)
self.dialog = dialog
self.key = key

def focusLost(self):
  self.dialog.keyLostFocus(self.key)


Now you connect your signals in a loop like this:

for key in keys:
 self.connect(key, SIGNAL(focusLost()), Magic(self, key).focusLost)

That assumes that self is the dialog and keys the list of key-widgets.

HTH,

Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PyQt Metaclass programming

2004-12-06 Thread Diez B. Roggisch
Hi,

 Would it help if sip.wrappertype was placed in the sip module dictionary
 so that you could sub-class it?

I ran into the same troubles and asked Gary for his solution. He offered me 
this neat trick for declaring my metaclass:

class SessionAware(type(QObject)):
 ...

I neverless think that sip.wrappertype should be exposed, as that would be a 
more natural approach to the problem - and more easy to document.

Regards,

Diez B. Roggisch

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] newbie question

2004-11-18 Thread Diez B. Roggisch
 What is the difference when naming a function as :
  def myfunction(self) def __myfunction__(self) and def __myfunction(self)

That actually a python question - comp.lang.python is a better forum to ask 
such questions. And as always: google is your friend :)

For an explanation of python naming conventions, read this:

http://docs.python.org/ref/specialnames.html
http://www.linuxgazette.com/issue54/pramode.html


The __foo syntax is described here:

http://www.sourcekeg.co.uk/www.python.org/doc/2.2.3/ref/atom-identifiers.html


Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PyQt

2004-11-17 Thread Diez B. Roggisch
 I understand that the principles of gui and http programming are different.
 I used some html terms in my email just to give people a hint of what I
 would like
 to do in my application.

Ok, so then this was a misunderstanding.

 When I say 'equivelant to the html frame tag' I just want to know if there
 is a Qt widget
 that has ie scrollbars and can be embedded to an existing widget.
 I just need some hints

QScrollView does that. 



Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Segmentation faults in pyqt

2004-07-30 Thread Diez B. Roggisch
Hi,

just for the record, so that when someone else encounters this: I found a cure 
for the problem. It appears that my font-handling was somehow corrupt - 
deactivating xfs and xfstt did do the trick for me. So its basically no PyQt 
problem, most probably not even a qt-problem but instead X11 multibyte gont 
related.

I just wanted to post this here so it gets into the archives.

Regrards,

Diez B. Roggisch

 When I gdb tut3.py (Unfortunately I'm no gdb expert - not anymore, at
 least...) I get a segfault with this stack:

 #0  0x41c84829 in _Xutf8DefaultDrawImageString ()
 from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
 #1  0x41c84f73 in _Xutf8DefaultDrawImageString ()
 from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
 #2  0x41c851ea in _Xutf8DefaultDrawImageString ()
 from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
 #3  0x41c8552f in _Xutf8DefaultDrawImageString ()
 from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
 #4  0x41c85868 in _Xutf8DefaultDrawImageString ()
 from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
 http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Segmentation faults in pyqt

2004-06-20 Thread Diez B. Roggisch
Hi,

 This smells fishy. I would start checking your system for old versions
 of sip/PyQt, especially in /usr/lib/python. If this guess doesn't
 match, send us the output of:

I did that  - I removed all things that appeared to be part of sip and pyqt, 
and reinstalled the packages. Now all in /usr/lib/python2.3/site-packages is 
from the same date (2004-05-21) and the libsip is from 2004-04-24. 

Still the same behaviour :(

 python -vc import qt

I attached the output - from what I understand, it looks ok.
  These are the various versions of sip/pyqt I tried:
 
  sip-4.0rc3 sip-snapshot-20040329
  sip-4.0rc4 sip-snapshot-20040501

 Note that changing sip always implies a PyQt (and dependants)
 recompile.

Sure - I of course did that.

 Good luck,

Thanks, but none so far :(


Regards,

Diez
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib/python2.3/site.pyc matches /usr/lib/python2.3/site.py
import site # precompiled from /usr/lib/python2.3/site.pyc
# /usr/lib/python2.3/os.pyc matches /usr/lib/python2.3/os.py
import os # precompiled from /usr/lib/python2.3/os.pyc
import posix # builtin
# /usr/lib/python2.3/posixpath.pyc matches /usr/lib/python2.3/posixpath.py
import posixpath # precompiled from /usr/lib/python2.3/posixpath.pyc
# /usr/lib/python2.3/stat.pyc matches /usr/lib/python2.3/stat.py
import stat # precompiled from /usr/lib/python2.3/stat.pyc
# /usr/lib/python2.3/UserDict.pyc matches /usr/lib/python2.3/UserDict.py
import UserDict # precompiled from /usr/lib/python2.3/UserDict.pyc
# /usr/lib/python2.3/copy_reg.pyc matches /usr/lib/python2.3/copy_reg.py
import copy_reg # precompiled from /usr/lib/python2.3/copy_reg.pyc
# /usr/lib/python2.3/types.pyc matches /usr/lib/python2.3/types.py
import types # precompiled from /usr/lib/python2.3/types.pyc
# /usr/lib/python2.3/warnings.pyc matches /usr/lib/python2.3/warnings.py
import warnings # precompiled from /usr/lib/python2.3/warnings.pyc
# /usr/lib/python2.3/linecache.pyc matches /usr/lib/python2.3/linecache.py
import linecache # precompiled from /usr/lib/python2.3/linecache.pyc
import encodings # directory /usr/lib/python2.3/encodings
# /usr/lib/python2.3/encodings/__init__.pyc matches 
/usr/lib/python2.3/encodings/__init__.py
import encodings # precompiled from /usr/lib/python2.3/encodings/__init__.pyc
# /usr/lib/python2.3/codecs.pyc matches /usr/lib/python2.3/codecs.py
import codecs # precompiled from /usr/lib/python2.3/codecs.pyc
import _codecs # builtin
# /usr/lib/python2.3/encodings/aliases.pyc matches 
/usr/lib/python2.3/encodings/aliases.py
import encodings.aliases # precompiled from /usr/lib/python2.3/encodings/aliases.pyc
# /usr/lib/python2.3/encodings/iso8859_15.pyc matches 
/usr/lib/python2.3/encodings/iso8859_15.py
import encodings.iso8859_15 # precompiled from 
/usr/lib/python2.3/encodings/iso8859_15.pyc
Python 2.3.4 (#2, May 29 2004, 03:31:27) 
[GCC 3.3.3 (Debian 20040417)] on linux2
Type help, copyright, credits or license for more information.
# /usr/lib/python2.3/site-packages/qt.pyc matches 
/usr/lib/python2.3/site-packages/qt.py
import qt # precompiled from /usr/lib/python2.3/site-packages/qt.pyc
import libsip # dynamically loaded from /usr/lib/python2.3/site-packages/libsip.so
import libqtc # dynamically loaded from 
/usr/lib/python2.3/site-packages/libqtcmodule.so
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] site
# cleanup[1] encodings
# cleanup[1] _codecs
# cleanup[1] zipimport
# cleanup[1] warnings
# cleanup[1] encodings.iso8859_15
# cleanup[1] types
# cleanup[1] qt
# cleanup[1] signal
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[1] libqtc
# cleanup[1] libsip
# cleanup[1] codecs
# cleanup[2] copy_reg
# cleanup[2] posixpath
# cleanup[2] os.path
# cleanup[2] stat
# cleanup[2] UserDict
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 83 unfreed ints in 6 out of 7 blocks
# cleanup floats
dlopen(/usr/lib/python2.3/site-packages/libsip.so, 2);
dlopen(/usr/lib/python2.3/site-packages/libqtcmodule.so, 2);


Re: [PyKDE] Segmentation faults in pyqt

2004-06-20 Thread Diez B. Roggisch

 libsip is SIP v3, not v4.

Yes, I currently used the debian packages, which are sip 3.10.1  and pyqt 3.11

In the meantime, I created a debug-builds of python 2.3.4, sip 4 rc4  and pyqt 
3.12

Still the same problem - so it appears to me that the problem is not something 
stale lying around.

When I gdb tut3.py (Unfortunately I'm no gdb expert - not anymore, at 
least...) I get a segfault with this stack:

#0  0x41c84829 in _Xutf8DefaultDrawImageString () 
from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
#1  0x41c84f73 in _Xutf8DefaultDrawImageString () 
from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
#2  0x41c851ea in _Xutf8DefaultDrawImageString () 
from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
#3  0x41c8552f in _Xutf8DefaultDrawImageString () 
from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
#4  0x41c85868 in _Xutf8DefaultDrawImageString () 
from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
#5  0x41c85e09 in destroy_fontdata () 
from /usr/X11R6/lib/X11/locale/lib/common/xomGeneric.so.2
#6  0x4142f461 in XCreateOC () from /usr/X11R6/lib/libX11.so.6
#7  0x4142e7f5 in XCreateFontSet () from /usr/X11R6/lib/libX11.so.6
#8  0x40d71345 in QMapPrivateQFont::Script, QString::clear () 
from /usr/lib/libqt-mt.so.3
#9  0x40d71fe1 in QInputContext::QInputContext () from /usr/lib/libqt-mt.so.3
#10 0x40d9122c in QWidget::createInputContext () from /usr/lib/libqt-mt.so.3
#11 0x40d58798 in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#12 0x40d6e7d4 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#13 0x40dd7498 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#14 0x40dd7348 in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#15 0x40dc3d51 in QApplication::exec () from /usr/lib/libqt-mt.so.3
#16 0x40a04027 in meth_QApplication_exec_loop (sipSelf=0x41beed6c, 
sipArgs=0x401a5034) at sipqtpart0.cpp:426590
#17 0x0810ea96 in PyCFunction_Call (func=0x4021137c, arg=0x401a5034, kw=0x0) 
at Objects/methodobject.c:73
#18 0x080c38d0 in call_function (pp_stack=0xb784, oparg=0) at 
Python/ceval.c:3439
#19 0x080bffe6 in eval_frame (f=0x8166d1c) at Python/ceval.c:2116
#20 0x080c1de6 in PyEval_EvalCodeEx (co=0x401fd658, globals=0x401c1df4, 
locals=0x401c1df4, args=0x0, argcount=0,
kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at 
Python/ceval.c:2663
#21 0x080ba6ac in PyEval_EvalCode (co=0x401fd658, globals=0x401c1df4, 
locals=0x401c1df4) at Python/ceval.c:537
#22 0x080e87a2 in run_node (n=0x401b9348, filename=0xbb84 
examples3/tut3.py, globals=0x401c1df4,
locals=0x401c1df4, flags=0xb958) at Python/pythonrun.c:1267
#23 0x080e8745 in run_err_node (n=0x401b9348, filename=0xbb84 
examples3/tut3.py, globals=0x401c1df4,
locals=0x401c1df4, flags=0xb958) at Python/pythonrun.c:1254
#24 0x080e8707 in PyRun_FileExFlags (fp=0x8155008, filename=0xbb84 
examples3/tut3.py, start=257,
globals=0x401c1df4, locals=0x401c1df4, closeit=1, flags=0xb958) at 
Python/pythonrun.c:1245
#25 0x080e7493 in PyRun_SimpleFileExFlags (fp=0x8155008, filename=0xbb84 
examples3/tut3.py, closeit=1,
flags=0xb958) at Python/pythonrun.c:862
#26 0x080e6cb7 in PyRun_AnyFileExFlags (fp=0x8155008, filename=0xbb84 
examples3/tut3.py, closeit=1,
flags=0xb958) at Python/pythonrun.c:659
#27 0x08055683 in Py_Main (argc=2, argv=0xba34) at Modules/main.c:415
#28 0x08054e36 in main (argc=2, argv=0xba34) at Modules/python.c:23


Googling gave me only one message from nov 2003 that stated a problem with 
ui-designer - nothing more so far.

Does this give you an idea? 

I also get a segfault when starting qt designer:

[EMAIL PROTECTED]:~/software/archives/PyQt-x11-gpl-3.12$ designer-qt3
KThemeStyle cache seems corrupt!

Segmentation fault

I wanted to chekt that to verify the message mentioned above - but this seems 
to be a different problem. I'll try to fix that one, too.

Regards,

Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Segmentation faults in pyqt

2004-06-19 Thread Diez B. Roggisch
Hi,

I've been struggling with this for a while now. I've got pyqt in various 
versions running on two machines - as debian testing package, or self-built. 
It works nice and smoothly.

But on the machine I care most about - the one sitting on my desk at home - it 
segfaults - regardless of what I try: latest versions of sip, snapshots and 
debian packages. Also no difference if I use python 2.2 instead of 2.3.

When stracing, the last thing I get from it is this:

lect(4, [3], NULL, NULL, NULL)= 1 (in [3])
read(3, \1%\336\0\0\0\0\0\0\0\377\277\326\251\r\10\30\356C\10 ..., 32) = 32
writev(3, [{1\0\v\0\1\0!\0, 8}, {-*-*-medium-r-*-*-16-*-ISO8859-1..., 33}, 
{\0\0\0, 3}], 3) = 44
read(3, 0xbfffefd0, 32) = -1 EAGAIN (Resource temporarily 
unavailable)
select(4, [3], NULL, NULL, NULL)= 1 (in [3])
read(3, \1%\337\0\17\0\0\0\1\0\377\277\326\251\r\10\30\356C\10..., 32) = 32
readv(3, [{:-ttf-andale mono-medium-r-norma..., 60}, {, 0}], 2) = 60
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++


These are the various versions of sip/pyqt I tried:

sip-4.0rc3 sip-snapshot-20040329
sip-4.0rc4 sip-snapshot-20040501

PyQt-x11-gpl-3.12   PyQt-x11-gpl-snapshot-20040502
PyQt-x11-gpl-snapshot-20040413

I didn't try every possible cobination - usually one of the sip4 and after 
that a snapshot. When 3.12 was released, I tried that. Building always went 
fine.

The only app that doesn't segfault is tut2.py.

Any pointers to how to debug this are appreciated - if neccessary, I'll built 
python, qt and sip/pyqt from scratch as debug versions, but I'd prefer to 
have someone saying that that actually makes debugging possible before I 
undetake that tedious task.

regardless from the trouble at home - where I got the chance to work with 
pyqt, it surely rocks


Regards,

Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] problem compiling PyKDE-3.11alpha7 kio module

2004-05-06 Thread Diez B. Roggisch
The sip version is 3.10 (snapshot-20040218-183), python is 2.3.3 and the 
system is a debian unstable with kde 3.2.2

This is the compilation error:

/usr/include/kde/kautomount.h: In constructor `
   sipKAutoUnmount::sipKAutoUnmount(const QString, const QString)':
/usr/include/kde/kautomount.h:107: error: `KAutoUnmount::~KAutoUnmount()' is
   private
kiopart0.cpp:89317: error: within this context
/usr/include/kde/kautomount.h: In constructor `
   sipKAutoMount::sipKAutoMount(bool, const QString, const QString, const
   QString, const QString, bool)':
/usr/include/kde/kautomount.h:70: error: `KAutoMount::~KAutoMount()' is 
private
kiopart0.cpp:89808: error: within this context

Any suggestions?

Regards,

Diez B. Roggisch

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] segfault with pyqt sip latest snapshots

2004-04-18 Thread Diez B. Roggisch
 I had this problem but with a different version of both. I found that
 removing and rebuilding and reinstalling both solved this problem.
 I don't know why the problem occured though.
 The second time i didn't use any build options at all, just python build.py

How exactly did you remove the installed stuff - is there a make target? 

Regards,

Diez

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] segfault with pyqt sip latest snapshots

2004-04-17 Thread Diez B. Roggisch
Hi,

I'm experiencing nasty segfaults with these components:

PyQt-x11-gpl-snapshot-20040413
sip-snapshot-20040329-196
Python 2.3.3 (#2, Feb 24 2004, 09:29:20)
[GCC 3.3.3 (Debian)] on linux2


Building  installing worked fine. The only example that works is tut2.py - 
everything else flashes for a splitsecond, then the program terminates.

any suggestions?

btw: I tried sip 4.0 rc 3 before - same thing there. And as there was no way 
to uninstall it, I simply overinstalled it using the sip snapshot. 
Afterwards, I recompiled/reinstalled pyqt without any problems.


Regards,

Diez B. Roggisch

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] DCOP Problems and Solutions

2003-11-18 Thread Diez B. Roggisch
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

 I'd be interested in hearing opinions on any of this. I'll make
 some decision on kab in the next few days depending on what
 feedback I get.

Now obviously I'm for putting kab in pyKDE :) I'm not sure what kjs exactly 
does - but working in python and then allowing java-script for scripting - 
doesn't make much sense to me. 

For the problem I want kab for - python play out its strenghs when dealing 
with conversions between different sorts of (string-based) formats. And 
there's plethorea of PDA/CellPhones out there, that could benefit from an 
fairly easy way to be synchronized, because all of them have their own 
format...

Of course I'm not sure what kdepim is up to  - maybe they will change great 
parts of the related interface, so putting effort into kab would make not 
much sense - at least now. Does anybody know what they are going to change 
for kde 3.2?

Regards,

Diez

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/umIKBUNnEs5xWG4RAg82AJ9LOfDpMA3lE9PzpKXrThaCx/YzKgCgms0L
7inbkTCV7A1fBuMUHkyZtpo=
=0YOq
-END PGP SIGNATURE-

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde