PySide\examples\opengl\overpainting.py errors [fixed]
-
a few notes on the following PySide\examples\opengl\overpainting.py a python version of http://qt-project.org/doc/qt-4.8/opengl-overpainting.html
everything will fail, with the error pasted at the end of this post, if glViewport() does not get ints
@
def resizeGL(self, width, height):
side = min(width, height)
glViewport(int((width - side) / 2), int((height - side) / 2), side, side)
@also its good practice to check the return values in paintEvent():
@
def paintEvent(self, event):
if self.painters > 0:
# Can't paint when another painter exists so exit early
# If we print() a warning here it will flood away any other warnings
return
painter = QPainter()
if painter.begin(self):
painter.setRenderHint(QPainter.Antialiasing)
...
painter.end()
del painter
@and again in formatInstructions():
@
def formatInstructions(self, width, height):
...
painter = QPainter()
if painter.begin(self.image):
painter.setRenderHint(QPainter.TextAntialiasing)
painter.setPen(Qt.white)
painter.drawText((width - rect.width())/2, border,
rect.width(), rect.height(),
Qt.AlignCenter | Qt.TextWordWrap, text)
painter.end()
del painter
@without the above changes the error you get is this
@
Traceback (most recent call last):
File "PySide\examples\opengl\overpainting.py", line 198, in paintEvent
self.resizeGL(self.width(), self.height())
File "PySide\examples\opengl\overpainting.py", line 227, in resizeGL
glViewport(((width - side) / 2), ((height - side) / 2), side, side)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
Traceback (most recent call last):
File "PySide\examples\opengl\overpainting.py", line 198, in paintEvent
self.resizeGL(self.width(), self.height())
File "PySide\examples\opengl\overpainting.py", line 227, in resizeGL
glViewport(((width - side) / 2), ((height - side) / 2), side, side)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
@and every frame the following
@
QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent
QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent
QPainter::begin: A paint device can only be painted by one painter at a time.
QPainter::setRenderHint: Painter must be active to set rendering hints
Traceback (most recent call last):
File "PySide\examples\opengl\overpainting.py", line 185, in paintEvent
glPushMatrix()
File "C:\Python33\lib\site-packages\OpenGL\error.py", line 208, in glCheckError
baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
err = 1283,
description = b'stack overflow',
baseOperation = glPushMatrix,
cArguments = ()
)
Traceback (most recent call last):
File "PySide\examples\opengl\overpainting.py", line 185, in paintEvent
glPushMatrix()
File "C:\Python33\lib\site-packages\OpenGL\error.py", line 208, in glCheckError
baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
err = 1283,
description = b'stack overflow',
baseOperation = glPushMatrix,
cArguments = ()
)
@also when creating a new post the bug tracker is listed as http://bugreports.qt.nokia.com/ not http://bugreports.qt-project.org/