Hi! Thanks for the reply!

I don't use qt designer actually, but I guess i can simply translate this 
part of the xml into code:

<customwidgets> 
    <customwidget> 
        <class>GLViewWidget</class>
        <extends>QOpenGLWidget</extends>
        <header>pyqtgraph.opengl</header>
    </customwidget> 
</customwidgets>


Do you think something like this would work?

class GLViewWidget(QOpenGLWidget):
    def __init__(*args, **kwargs):
        super(GLViewWidget, self).__init__(*args, **kwargs)

Maybe I am not translating <header>pyqtgraph.opengl</header> , right?

Thanks for the help!

Il giorno lunedì 20 aprile 2020 13:03:56 UTC+2, Nick PV ha scritto:
>
> Try to promote your OpenGL widget on PyQt form at PyQt designer:
>
>
> some hints : 
> https://stackoverflow.com/questions/53798877/pyqtgraph-opengl-vs-opengl-gl-how-to-display-axis-at-pyqt5-opengl-embedded-wid
>
>
>
> On Saturday, April 18, 2020 at 9:57:19 AM UTC-7, Daniele Dolci wrote:
>>
>> I am trying to create a 3d plot of a cube and add it to my ui. after lots 
>> of tests and following the examples I got this code to work:
>>
>> # import PyQt5
>> # from PyQt5 import QtGui, QtCore
>> # import numpy as np
>> # import pyqtgraph as pg
>> # import pyqtgraph.opengl as gl
>>
>> # -*- coding: utf-8 -*-
>> """
>> Demonstrates GLVolumeItem for displaying volumetric data.
>>
>> """
>>
>> ## Add path to library (just for examples; you do not need this)
>>
>> from pyqtgraph.Qt import QtCore, QtGui
>> import pyqtgraph.opengl as gl
>>
>> app = QtGui.QApplication([])
>> w = gl.GLViewWidget()
>> w.opts['distance'] = 200
>> w.show()
>> w.setWindowTitle('pyqtgraph example: GLVolumeItem')
>>
>> # b = gl.GLBoxItem()
>> # w.addItem(b)
>> g = gl.GLGridItem()
>> g.scale(10, 10, 1)
>> w.addItem(g)
>>
>> import numpy as np
>>
>> vertexes = np.array([[1, 0, 0], #0
>>                      [0, 0, 0], #1
>>                      [0, 1, 0], #2
>>                      [0, 0, 1], #3
>>                      [1, 1, 0], #4
>>                      [1, 1, 1], #5
>>                      [0, 1, 1], #6
>>                      [1, 0, 1]])#7
>>
>> colors = np.array([[1,0,0,1] for i in range(12)])
>>
>> faces = np.array([[1,0,7], [1,3,7],
>>                   [1,2,4], [1,0,4],
>>                   [1,2,6], [1,3,6],
>>                   [0,4,5], [0,7,5],
>>                   [2,4,5], [2,6,5],
>>                   [3,6,5], [3,7,5]])
>>
>> cube = gl.GLMeshItem(vertexes=vertexes, faces=faces, faceColors=colors,
>>                      drawEdges=True, edgeColor=(0, 0, 0, 1))
>>
>> w.addItem(cube)
>>
>> ax = gl.GLAxisItem()
>> w.addItem(ax)
>>
>> ## Start Qt event loop unless running in interactive mode.
>> if __name__ == '__main__':
>>     import sys
>>
>>     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
>>         QtGui.QApplication.instance().exec_()
>>
>>
>>
>> For some reason whenever I replace:
>>
>>
>> from pyqtgraph.Qt import QtCore, QtGui
>>
>> with
>>
>> from PyQt5 import QtWidgets, QtCore, QtGui
>>
>>
>> I start to get this error:
>>
>> Traceback (most recent call last):
>>   File 
>> "/usr/local/lib/python3.7/dist-packages/pyqtgraph/opengl/GLViewWidget.py", 
>> line 188, in paintGL
>>     self.setProjection(region=region)
>>   File 
>> "/usr/local/lib/python3.7/dist-packages/pyqtgraph/opengl/GLViewWidget.py", 
>> line 110, in setProjection
>>     glMatrixMode(GL_PROJECTION)
>>   File "/usr/lib/python3/dist-packages/OpenGL/error.py", line 232, in 
>> glCheckError
>>     baseOperation = baseOperation,
>> OpenGL.error.GLError: GLError(
>>    err = 1282,
>>    description = b'invalid operation',
>>    baseOperation = glMatrixMode,
>>    cArguments = (GL_PROJECTION,)
>> )
>>
>>
>> For this reason I wasn't able to get this to work in my ui. Any idea what 
>> that might depend on?
>>
>>
>> Thanks!
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/6058040a-f8c1-46a8-9e53-fa20e71963d5%40googlegroups.com.

Reply via email to