*** GMX Spamverdacht *** Re: [PyQt] ImportError: No module named QtOpenGL

Andreas Pakulat apaku at gmx.de
Sun Apr 29 05:25:37 BST 2007


On 28.04.07 21:13:38, sole at esrf.fr wrote:
> Quoting Andreas Pakulat <apaku at gmx.de>:
> 
> > On 28.04.07 23:31:53, Pradnyesh Sawant wrote:
> > > Hello,
> > > I've written a small pyqt4 code, which on running on an ubuntu 6.10
> > > system gives me the foll error:
> > > $ python2.4 updLbl.py
> > > Traceback (most recent call last):
> > >  File "updLbl.py", line 1, in ?
> > >    import PyQt4.Qt as qt
> >
> > This is wrong, you don't want to do that.
> 
> That is not wrong. It just forces him to have all the packages installed and it
> is never wrong if he builds PyQt4 himself because Qt.py would only try to import
> the modules he built. 

If it forces him to install all pyqt4 packages, even the ones he doesn't
want to use then using this import is wrong.

> In his current situation he could even comment the 
> 
> "from PyQt4.QtOpenGL import *" 
> 
> line of Qt.py if he does not intend to use OpenGL.

Which means changing a system file which is a bad thing to do. Other
software may rightfully rely on having that line there and he has to do
that change every time he updates his PyQt4 packages.

> By other hand I find pretty convenient not to have to care about if a module or
> a constant comes from QtCore or from QtGui, specially if I am porting PyQt3 code
> to PyQt4 because minimizes changes. I guess that was one of the main motivations
> to have Qt.py as part of the standard installation. Afterwards it is just a
> question of taste :)

Right, the motivation for the Qt.py package is simply convenience for
porting PyQt3 code. Which doesn't mean you should use it in new PyQt4
programs. Using something like this creates enough convience while
preserving a clean global namespace:

from PyQt4 import QtCore,QtGui
from PyQt4.QtGui import QWidget, QPushButton <other classes you use very often>

Andreas

-- 
Are you sure the back door is locked?


More information about the PyQt mailing list