[PyKDE] PyQwt example issues

Gerard Vermeulen gerard.vermeulen at grenoble.cnrs.fr
Mon Feb 21 05:23:14 GMT 2005


On Mon, 21 Feb 2005 00:30:11 +0100
Hans-Peter Jansen <hpj at urpla.net> wrote:

> Hi Gerard,
> 
> I found these issues with the examples of PyQwt 4.1a and
> Python version: 2.3
> sip version: 4.2
> Qt version: 3.2.1
> PyQt version: 3.14
> 
> python DialDemo.py 
> Traceback (most recent call last):
>   File "DialDemo.py", line 436, in ?
>     main(sys.argv)
>   File "DialDemo.py", line 419, in main
>     demo = make()
>   File "DialDemo.py", line 427, in make
>     demo.addTab(CompassGrid(demo), "Compass")
>   File "DialDemo.py", line 18, in __init__
>     self.__createCompass(pos)
>   File "DialDemo.py", line 28, in __createCompass
>     colorGroup.setColor(c, QColor())
> TypeError: argument 1 of QColorGroup.setColor() has an invalid type
> 
> Uncommenting the offending lines (27+28) results in:
> 
> Traceback (most recent call last):
>   File "DialDemo.py", line 436, in ?
>     main(sys.argv)
>   File "DialDemo.py", line 419, in main
>     demo = make()
>   File "DialDemo.py", line 427, in make
>     demo.addTab(CompassGrid(demo), "Compass")
>   File "DialDemo.py", line 18, in __init__
>     self.__createCompass(pos)
>   File "DialDemo.py", line 101, in __createCompass
>     if colorGroup.color(c).isValid():
> TypeError: argument 1 of QColorGroup.color() has an invalid type
> 
> and:
> 
> python ICompass.py
> Traceback (most recent call last):
>   File "ICompass.py", line 73, in ?
>     references = test_python()
>   File "ICompass.py", line 32, in test_python
>     result = compass()
>   File "ICompass.py", line 24, in compass
>     c = Compass()
>   File "ICompass.py", line 11, in __init__
>     self.setFrameShadow(QFrame.Raised)
> TypeError: argument 1 of QwtDial.setFrameShadow() has an invalid type
> 
> Both smell suspiciously like sips new enum handling is biting here..
>
Expect a new release which fixes this within a few days.

The 'setup.py' installation script has survived the move to SIP-4.2,
but the 'configure.py' script has been broken by work with SIP-4.2.

BTW, a portable way of looping through an enum type which has been
designed to be looped through (those with a sentinel), is to define
a helper function:

def enumColorRoles():
    """Masks the change in enum/int type checking new in SIP-4.2.x
    """
    try:
        return [
            QColorGroup.ColorRole(i) for i in range(QColorGroup.NColorRoles)
            ]
    except AttributeError:
        return range(QColorGroup.NColorRoles)

# enumColorRoles()

which can be used as follows:

        for cr in enumColorRoles():
            colorGroup.setColor(cr, QColor())

Gerard




More information about the PyQt mailing list