How to interact with PyQt5.QtWidgets openGLWidget
using pyqtgraph.opengl
instead of OpenGL.GL
?
I need to make a next graphical output to openGLWidget
on the PyQt5 form:
def plot_line(line):
pl_line = np.array(line)
color = (0.0, 0.0, 200.0, 0.5)
newline = gl.GLLinePlotItem(pos=pl_line, color=color, width=5, antialias=False)
w.addItem(newline)
w.show()
line1 = [(-33.13, 1004.82, -125.7), (21.38, 1059.32, -162.03)]
plot_line(line1)
Here I have an example where I have a UI with a button and openGLWidget and I want to make a graphical output to openGLWidget which I defining at plot_line()
function. How should I perform such output?
import sys
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QApplication, QDialog
from PyQt5.uic import loadUi
import pyqtgraph.opengl as gl
class app_1(QDialog):
def __init__(self):
super(app_1,self).__init__()
loadUi('Qt_test_Ui.ui', self)
self.setWindowTitle('Test GL app')
self.pushButton.clicked.connect(self.on_push_b1)
@pyqtSlot()
def on_push_b1(self):
self.openGLWidget.paintGL = self.paintGL()
def paintGL(self):
w = self.openGLWidget
axis = gl.GLAxisItem() # show 3D axis
w.addItem(axis)
app=QApplication(sys.argv)
wid=app_1()
wid.show()
sys.exit(app.exec_())