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

Paul Giannaros ceruleanblaze at gmail.com
Sat Mar 10 00:09:19 GMT 2007


On Thursday 08 March 2007 19:26, mikos at centrum.cz wrote:
> >> 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)
>

This is by no means the Right Solution but I've ported the example to Python 
before by writing a simple C++ Python module (qargb) that has one method that 
sets up ARGB visuals and creates the QApplication accordingly. I could send 
the files if you're interested.



More information about the PyQt mailing list