[PyQt] PyQt4.7.7 QGraphics Effetc dont work

Hans-Peter Jansen hpj at urpla.net
Wed Oct 20 19:26:43 BST 2010


[please keep the mailing list cc'ed at least, and personal reply]

On Wednesday 20 October 2010, 19:25:33 leo kirotawa wrote:
> Sorry,
> I should have  shown more details.
> So, I installed the PyQt4.7.7 in my ubuntu 9.04 through this link
> http://www.riverbankcomputing.co.uk/software/pyqt/download.
>
> Installing this way the files come with a folder called examples in
> it has a other folder called effect. In this folder has some samples
> the app using the new classes Effect of PyQt4.7.7. When I tried run
> the sample lighting.py it show this message:
>
> File "lighting.py", line 66, in setupScene
>     effect = QtGui.QGraphicsDropShadowEffect(self)
> AttributeError: 'module' object has no attribute
> 'QGraphicsDropShadowEffect'
>
> So, my questions are: this trouble is cause my python version 2.6.2
> or my ubuntu version 9.04? Or cause other reasons? For other examples
> like : /examples/graphicsview/anchorlayout.py show the same message.
>
> []'s

Here's the standard procedure in such cases:

$ grep -r QGraphicsDropShadowEffect sip/
sip/QtGui/qapplication.sip:        {sipName_QGraphicsDropShadowEffect, &sipType_QGraphicsDropShadowEffect, -1, 49},
sip/QtGui/qgraphicseffect.sip:class QGraphicsDropShadowEffect : QGraphicsEffect
sip/QtGui/qgraphicseffect.sip:    QGraphicsDropShadowEffect(QObject *parent /TransferThis/ = 0);
sip/QtGui/qgraphicseffect.sip:    virtual ~QGraphicsDropShadowEffect();
sip/QtGui/qgraphicseffect.sip:    QGraphicsDropShadowEffect(const QGraphicsDropShadowEffect &);

Ergo, the class is defined in sip/QtGui/qgraphicseffect.sip.

$ less sip/QtGui/qgraphicseffect.sip
[...]
%If (Qt_4_6_0 -)

class QGraphicsEffect : QObject
{
%TypeHeaderCode
#include <qgraphicseffect.h>
%End

Ergo, QGraphicsEffect is available from Qt 4.6.0 onwards only.

Let us see the output of:

    try:
        from PyQt4 import QtCore
    except ImportError:
        print "PyQt4 not installed"
    else:
        print "Qt4 version:", QtCore.QT_VERSION_STR
        print "PyQt4 version:", QtCore.PYQT_VERSION_STR

I would bet any money, that Qt is below 4.6.0. I have no idea, if any 
ubuntu repo has a newer Qt available. 

[To all you Ubuntu users out there: I'm willing to provide current PyQt 
related packages for your beloved OS, similar to what I provide for
openSUSE here:

https://build.opensuse.org/project/show?project=home%3Afrispete%3APyQt
https://build.opensuse.org/project/show?project=home%3Afrispete%3APyQt-next
https://build.opensuse.org/project/show?project=home%3Afrispete%3Apython3

but it takes some form of funding for this, since it is a considerable 
amount of work to be done.

The build service supports Ubuntu 8.04, 9.04, 9.10, and 10.04 ATM.]

Please disregard this shameless advertising!

A warning message for these cases wouldn't harm. How about providing us 
one as a janitorial task in return to be able to use this beautiful piece 
of code? [This is not meant as a joke!]

Pete


More information about the PyQt mailing list