[PyQt] PyQt5 QStyleOptionButton enum problem

Florian Bruhin me at the-compiler.org
Tue Oct 27 15:57:01 GMT 2015


* Damon Lynch <damonlynch at gmail.com> [2015-10-27 20:32:59 +0500]:
> I have no idea if this is expected behaviour, but this definitely does not
> work with Python 3.4.3+ and PyQt 5.4.2:
> 
> QStyleOptionButton.None

That's because that's a SyntaxError - I think for other similar
situations it got aliased to None_ instead by PyQt, but that doesn't
seem to be the case here.

FWIW, you can do getattr(QStyleOptionButton, 'None') instead.
To ensure compatibility with later versions (when this is fixed, which
I guess will happen), you could do:

    try:
        foo = QStyleOptionButton.None_
    except AttributeError:
        foo = getattr(QStyleOptionButton, 'None')

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20151027/d0544a60/attachment.sig>


More information about the PyQt mailing list