PyQt4: I hate you

11 Comments

No, that’s not true… if I didn’t love Qt Designer and python so much, I wouldn’t tolerate PyQt, so I must secretly love PyQt. UGH BAD LOVE. And py2app is like the foul-smelling friend of PyQt that comes around once a week to get both of them drunk and loud at 3:00 AM.

So I spent the entire morning checking, tweaking and re-checking my import statements, my .profile, my paths, my app, my resources, my plugins — all because my library source wasn’t making it into my py2app-generated app. You know — these source files that are imported in every one of my python modules? Yeah, not there. Didn’t make the cut. Sorry.

I checked my notes from the LAST time I went through this, with no results. I Googled. I checked forums. I googled again. I emacsed. I sourced. I logged and moved and copied and pasted.

And then a little after lunch a tiny voice said “Why don’t you use the –no-strip flag?”

That voice was smart. A little bit of this action got me a working app:

python setup.py py2app –include sip –no-strip

Yeah, at 44 Mb it’s kind of fatty. But you know what I’m gonna do about that. NOTHING.

FOR A WHILE.

But NOW… oh ho ho NOW my jpeg-based thumbnails aren’t showing up. You wanna know why? Because apparently Qt’s jpeg support is a plugin. The last time I had to tangle with a plugin was phonon, and that worked OK until PyQt’s failure to wrap an obscure phonon object caused a persistent and deadly threading error. How did I get around that, you ask? I DIDN’T. I used the built-in python modules wave and pyaudio and rewrote what I had been getting from phonon. Don’t talk to me about phonon. Phonon is dead to me!

Anyhoo. Such is technology.

Time to copy over some plugins…

**Update 5:07 PM**

I had been getting this message when my application attempted to load a jpeg-based QPixmap:


On Mac OS X, you might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
QObject::moveToThread: Current thread (0x13b11f40) is not the object’s thread (0x1e8760).

I found this. All I did was add a blank qt.conf to the myApp.app/Contents/Resources folder, and this error ceased. You’ll notice that’s all the bug-tracker describes — how to get the error to go away — not how to get the imageformats plugin to work.

I am still trying all sorts of different things to get my application to pick up the imageformats’ jpeg plugin… Will update…

Update 3/5

Nope. Couldn’t make the plugin happen. Fortunately — VERY fortunately — I had the option and ability to convert and store the JPEGs as PNGs on-the-fly, so I can use PNGs, which are native to Qt and work ju-u-u-ust fine when all apped up.

Someday I’ll be able to make an apped-up Qt plugin work, but it hasn’t happened yet.

Update 9/1

After much research and experimentation I came to this conclusion about trying to use plugins in a py2app-generated PyQt app: I can’t. But there’s a workaround.