This isn't quite my problem. I've attached some test scripts that show
where the error occurs. The only major difference in that in one case I am
embedding the GL widget into a main window, and in another case I am not. I
don't think it is a driver issue *because* test2.py works without issues.
For context, I am running the following versions:
Python 3.8
PyQt5 5.15.1
pyqtgraph 0.12.0
numpy 1.19.4
On Monday, 5 April 2021 at 00:06:47 UTC-3 Nit wrote:
> Hi, you might need to place the place the graphicsview inside gridlayout,
> add GLviewwidget onto the layout
>
> #Create object form GLviewWidget
> self.viewt = gl.GLViewWidget()
> #create grid features
> self.xgrid.rotate(90, 0, 1, 0)
> self.xgrid.translate(-10, 0, 0)
> #add grid item to GLviewWidget object
> self.viewt.addItem(self.xgrid)
>
> #This should solve the issue
> self.layout_parent = QGridLayout(self.graphicsView)
> self.layout_parent.setContentsMargins(20, 20, 20, 20)
> self.layout_parent.addWidget(self.viewt)
>
> Let me know
>
> On Sunday, April 4, 2021 at 6:31:19 AM UTC-7 [email protected] wrote:
>
>> Hello everyone,
>>
>> I'm fairly new to PyQtGraph, and for the most part I have been having
>> tremendous success. I am creating an application that does some analysis on
>> objects in 3D space, and generates plots based on their geometry. Currently
>> my plots are all 2D, with an image view and linked axes to show data
>> arising from the underlying model geometry, however I was hoping to also
>> include a 3D plot *showing* the geometry. Going through the PyQtGraph
>> examples, the GlScatterPlotItem looks to be precisely what I am looking for.
>>
>> Oddly enough, the example runs perfectly fine, however when I try to
>> implement this into my application I got an error. My first instinct was to
>> bring the GlViewWidget outside of my GraphicsLayoutWidget, and plot
>> independently. This worked.. kind of. I can add a GridItem to the
>> GlViewWidget, and that renders fine - I can interact with it as I can in
>> the examples. However, upon trying to add a GlScatterPlotItem I get the
>> following error:
>>
>> line 114, in addItem
>> self.checkOpenGLVersion('Error while adding item %s to GLViewWidget.'
>> % str(item))
>>
>> line 535, in checkOpenGLVersion
>> verString = glGetString(GL_VERSION)
>>
>> line 415, in __call__
>> return self( *args, **named )
>>
>> line 230, in glCheckError
>> raise self._errorClass(
>> OpenGL.error.GLError: GLError(
>> err = 1282,
>> description = b'invalid operation',
>> baseOperation = glGetString,
>> cArguments = (GL_VERSION,)
>> )
>>
>> What baffles me is that the examples work without issue. Some googling
>> lead me to upgrading mesa drivers, however that did not seem to fix the
>> issue - Any ideas on what I could do to make this work?
>>
>>
--
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/4b9da0ec-c488-4696-aab0-664fecaafd83n%40googlegroups.com.
from PyQt5 import QtWidgets, uic
import pyqtgraph.opengl as gl
import sys
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
uic.loadUi('test.ui', self)
def main():
app = QtWidgets.QApplication(sys.argv)
m = MainWindow()
grid = gl.GLGridItem()
m.openGLWidget.addItem(grid) # <-- Works, no problem.
pos = [(0, 0, 0), (0, 1, 0)]
scatter_plot = gl.GLScatterPlotItem(pos=pos)
m.openGLWidget.addItem(scatter_plot) # <-- Throws error
m.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="GLViewWidget" name="openGLWidget"/>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>GLViewWidget</class>
<extends>QOpenGLWidget</extends>
<header>pyqtgraph.opengl</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
import pyqtgraph as pg
import pyqtgraph.opengl as gl
import numpy as np
app = pg.mkQApp("GLScatterPlotItem Example")
w = gl.GLViewWidget()
w.opts['distance'] = 50
w.show()
g = gl.GLGridItem()
w.addItem(g) # <-- Works no problem
pos = np.array([(0, 0, 0), (0, 1, 0)])
size = np.array([10, 10])
scatter_plot = gl.GLScatterPlotItem(pos=pos, size=size) # < -- This works here.
w.addItem(scatter_plot)
if __name__ == '__main__':
pg.mkQApp().exec_()