[PyQt] New PyQt APIs

Martin Teichmann lkb.teichmann at gmail.com
Mon Feb 15 13:06:20 GMT 2010

Hi List,

I just browsed through the documentation of the
new signal system and also for the pythonized
APIs for QString and alike. They're great,
since this will make programming PyQt4 much
more straight forward and especially more pythonic.

There are, however, some oddities I think, which
I would like to share for possible improvements
of a future even better PyQt.

So, the first thing is that I consider the
choice of the names pyqtSignal and pyqtSlot
a bit overkill - why are they not just called
Signal and Slot (or signal and slot)? In case
one is writing a program heavily using PyQt,
its obvious that we're talking about PyQt signals
and slots - and if this is not the case,
one can always write QtCore.signal, which
is then clear.

The other thing I stumbled about is the
sip.setapi thing. It's a bit strange a thing,
especially because it has to be called
before other imports, making the imports
a bit cluttered. I propose to make our own
__future__ module (or package), so
that you can just write:

from PyQt4.__future__ import QString

(in a package PyQt4.__future__ a module
QString contains the lines

import sip
sip.setapi('QString', 2)

that should do the job.)

This also has the advantage that every
python programmer will put that line to
the very beginning - that's what you have
to do with __future__ statements anyway.

Unfortunately, I guess it is impossible to
achieve the python semantics whereas
__future__ statements only apply to the
current module. That would be nice, but
I guess impossible.

So, I'm looking forward to comments on
my ideas.



More information about the PyQt mailing list