[PyQt] problem creating QApplication with argb visual

David Boddie dboddie at trolltech.com
Fri May 30 19:31:34 BST 2008

On Fri May 30 12:56:57 BST 2008, Lev Shamardin wrote:

> I'm trying to port ARGB window example 
> (http://labs.trolltech.com/page/Graphics/Examples/Examples1) to PyQt4. I've 
> wrapped all calls to Xlib with ctypes, and now stuck with the following
> problem: 
> If I pass only the Display pointer to the QApplication constructor,
> everything works fine and as expected. But if I also pass the visual and
> colormap I start to get complaints from the X11 like these and application
> window does not appear:
> X Error: BadMatch (invalid parameter attributes) 8
>    Major opcode: 1 (X_CreateWindow)
>    Resource id:  0x68
> X Error: BadDrawable (invalid Pixmap or Window parameter) 9
>    Extension:    155 (RENDER)
>    Minor opcode: 4 (RenderCreatePicture)
>    Resource id:  0x5000002
> X Error: BadWindow (invalid Window parameter) 3
>    Major opcode: 18 (X_ChangeProperty)
>    Resource id:  0x5000002
> etc...
> Any ideas what can be wrong? Here is my source code just in case:
> http://pastebin.ca/1034001

I tried your code on three different X servers: the one I use on my display,
another that's being used via VNC, and a third that is being displayed with
Xephyr. The first two gave me this traceback:

>>> app = QArgbApplication([])
screen: 0
eventBase: 0 errorBase: 180
nvi: 0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dboddie/python/pastebin.ca-1034001.py", line 120, in __init__
    self.__visual = visual
UnboundLocalError: local variable 'visual' referenced before assignment

The one used with Xephyr gave me this before terminated the Python process:

screen: 0
eventBase: 0 errorBase: 136
nvi: 1
visual = 0x08277a48, colormap = 0x00e00001
ext_data None visualid 57 c_class 4 red_mask 16711680 green_mask 65280 
blue_mask 255 bits_per_rgb 8 map_entries 256
Found ARGB visual, starting app...
Alarm clock

I have no idea whether your code is doing all the right things with Xlib.
For testing purposes, I just assumed that it is, but I think you may need to
ask a Python Xlib guru. (Maybe there are a few reading this list.)

I hope this helps you track down the problem.

David Boddie
Lead Technical Writer, Trolltech ASA

More information about the PyQt mailing list