[PyQt] QStyleOptionButton.text cannot be updated once accessed

Ales Erjavec ales.erjavec324 at gmail.com
Thu Sep 29 10:39:18 BST 2016


QStyleOptionButton.text attribute cannot be updated it it was
previously assigned to or just accessed

The following fails with an assertion error:

======

from PyQt5.QtWidgets import QStyleOptionButton
opt = QStyleOptionButton()
opt.text = "Hello"
assert opt.text == "Hello"  # This works,

opt.text = "world!"
assert opt.text == "world!" # This fails, opt.text is still "Hello"


opt = QStyleOptionButton()
print(opt.text)  # access
opt.text = "Hello"
assert opt.text == "Hello"  # This fails, opt.text is still ''

======

Python: 3.5
PyQt: 5.7  (installed from the official wheel)
OS: OS X 10.11.6 El Capitan


More information about the PyQt mailing list