[PyQt] Re: [PyKDE] PyQt 4 doesn't allow to create an application, given an already open display. How to solve it?

mikos at centrum.cz mikos at centrum.cz
Thu Mar 8 19:26:20 GMT 2007


>>
>> Ironically ctypes doesn't provide the necessary C API to do this. However
>> if (in Python) you can get the address of the real data structure as a
>> number (ctypes.addressof() ?) then you can create a sip.voidptr from it and
>> I can add the ctors to accept that.
>>
>
>
> import ctypes
> import sip
>
> class Display(ctypes.Structure):
>         pass
>
> xlib = ctypes.CDLL('libX11.so.6')
> xlib.XOpenDisplay.restype = ctypes.POINTER(Display)
> xlib.XOpenDisplay.argtypes = [ctypes.c_char_p]
>
> display = xlib.XOpenDisplay(':0.0')
>
> dvp = ctypes.cast(display,ctypes.c_void_p)
> print dvp.value
> svp = sip.voidptr(dvp.value)
> print int(svp)
>
>
> I think the same thing could also be accomplished entirely in c++, not sure if 
> it would be worth it.
>
> Matt

Great, thanks! So this looks like support for it can be added to PyQt4 in the end...
Will somebody do it?

Btw. same integer like from your dvp.value and int(svp) is returned by this:
print ctypes.addressof(display.contents)

Does it have also some useful meaning?

Michal Krenek (Mikos)



More information about the PyQt mailing list