[PyKDE] QtCore.Qt and QtGui.Qt

Phil Thompson phil at riverbankcomputing.co.uk
Thu Mar 2 09:46:03 GMT 2006

On Thursday 02 March 2006 9:07 am, Sreeram Kandallu wrote:
> Hi
> I just have a couple of questions regarding conventions that are being
> followed in PyQt4.
> I'm using the '20060226' snapshots of PyQt4 and Sip, and i noticed that
> the Qt namespace is present in *both* QtCore and QtGui! why is that?
> Also, enums like Qt::WindowFlags are present in QtCore.Qt,
> whereas a few enums like Qt::WhiteSpaceMode are present in QtGui.Qt!
> What is the reasoning for this?

The short answer is that the Python objects are placed in the module 
corresponding to the C++ library in which they are implemented.

Up until recently I had planned (and partially implemented) the idea that a 
namespace would only appear once and that any objects implemented in other 
modules would be placed in it. In other words...

from PyQt4 import QtCore
from PyQt4 import QtGui

...would give different output for each dir(). This was a pain to implement 
and (I thought) more confusing for the user - I'm not saying which of those 
carried the most weight.

Basically, namespaces are second class citizens compares to modules.


More information about the PyQt mailing list