[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 00:43:08 GMT 2007


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.




More information about the PyQt mailing list