Hello Pyqtgraph community,

I want to create a "fixed" text object in a 3D interactive plot generated 
in PyQtGraph. This text object will contain simulation-related information 
and should be visible at all times, regardless if you zoom in/out or pan to 
the left or right; and the location of the window should not change.

So far all the solutions I have found, create a text object that moves as 
the scaling of the axes changes. For example, the code below prints text on 
3D axis, but once you zoom in/out the text moves all over the place. Any 
ideas would be greatly appreciated.

Thanks



from pyqtgraph.Qt import QtCore, QtGui

import pyqtgraph.opengl as gl

from pyqtgraph.opengl.GLGraphicsItem import GLGraphicsItem


class GLTextItem(GLGraphicsItem):

    """

    Class for plotting text on a GLWidget

    """


    def __init__(self, X=None, Y=None, Z=None, text=None):

        GLGraphicsItem.__init__(self)

        self.setGLOptions('translucent')

        self.text = text

        self.X = X

        self.Y = Y

        self.Z = Z


    def setGLViewWidget(self, GLViewWidget):

        self.GLViewWidget = GLViewWidget


    def setText(self, text):

        self.text = text

        self.update()


    def setX(self, X):

        self.X = X

        self.update()


    def setY(self, Y):

        self.Y = Y

        self.update()


    def setZ(self, Z):

        self.Z = Z

        self.update()


    def paint(self):

        self.GLViewWidget.qglColor(QtCore.Qt.white)

        self.GLViewWidget.renderText(self.X, self.Y, self.Z, self.text)



if __name__ == '__main__':

    # Create app

    app = QtGui.QApplication([])

    w1 = gl.GLViewWidget()

    w1.resize(800, 800)

    w1.show()

    w1.setWindowTitle('Earth 3D')


    gl_txt = GLTextItem(10, 10, 10, 'Sample test')

    gl_txt.setGLViewWidget(w1)

    w1.addItem(gl_txt)


    while w1.isVisible():

        app.processEvents()

python-3.x

-- 
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/11a9f5a2-4d43-4fed-acab-342a1e5230fan%40googlegroups.com.

Reply via email to