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

Matt Newell newellm at blur.com
Thu Mar 8 08:40:29 GMT 2007


On Thursday 08 March 2007 00:07, Ulrich Berning wrote:
> mikos at centrum.cz wrote:
> >Eh, I have just realized that I have replied directly to Phil Thompson,
> > not to this list (this is because I have used unfamiliar webmail client).
> > So this is our conversation:
> >
> >*** Me: ***
> >You can look at that example by Zack Rusin, it is very simple, here is
> > code: http://ktown.kde.org/~zrusin/examples/argb.tar.bz2 (look at
> > main.cpp)
> >
> >That Display instance come directly from xlib, it is created by
> > XOpenDisplay: http://lxr.freedesktop.org/ident?i=XOpenDisplay
> >
> >In Python, I am using ctypes module to directly access xlib (libX11)
> >and call XOpenDisplay.
> >
> >*** Phil: ***
> >I meant, in the context of PyQt. PyQt needs to know about the type.
> >
> >*** Me: ***
> >I can't help you much in this, I don't know much about ctypes, I have only
> > learned it because I want to create ARGB windows with PyQt (and then I
> > realized that I can't do it because PyQt doesn't support it). But you can
> > try this code:
> >
> >### Python code ###
> >import ctypes
> >
> >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')
> >### End of Python code ###
> >
> >This will create 'display' object, which is pointer to 'Display' structure
> >(which is derived from standard ctypes.Structure).
> >
> >But this is all I can tell you, as I said I don't know any details about
> > this process, only that it works (I have tried creating window with pure
> > xlib).
> >
> >Ctypes are standard module in python 2.5 (for Python 2.4 it is external
> >module), so I think PyQt should support it.
>
> The ctypes extension doesn't build on AIX, HP-UX, IRIX and Solaris. With
> some changes, it may build on IRIX and Solaris, because libffi has been
> ported to these platforms. On AIX and HP-UX, you have definitely lost.
> I've never understood, why ctypes became a standard module.
>
> PyQt works on the above platforms. Making it dependent on the ctypes
> extension seems to be a bad idea.
>

Display is just a pointer.  I think PyQt could support accepting a ctypes 
pointer as an arguement without depending on ctypes being available.  The 
ctypes pointer is simply passed as a PyObject * and regular python api calls 
are used to check that it is indeed a ctypes pointer, and to get the value.

Matt




More information about the PyQt mailing list