pyqtgraph/examples/GLTextItem.py
shikishima-TasakiLab f13002b251
Add "GLTextItem" (#1776)
* Add GLTextItem

* Fixed DocString.

* Delete unnecessary function.

* Add `from .items.GLTextItem import *`

* Add an example.

* [Combines two `isinstance()` into one.](https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046120)

* [Combines two `isinstance()` into one.](https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046120)

* [The long code has been broken up into separate lines.](https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046234)

* [Moved `pos`, `color`, `text`, and `font` to the `__init__` method.](https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633047216)

* Add `import initExample` and fix `mkQApp().exec_()` to `pg.exec()` (https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046878, https://github.com/pyqtgraph/pyqtgraph/pull/1776#discussion_r633046781)

* Fix `pg.exec()` to `pg.mkQApp().exec()`

* Revert "Fix `pg.exec()` to `pg.mkQApp().exec()`"

This reverts commit 67d397d803.

* Remove type-hints.

* Fix `glColor4d(float(self.color[0]), float(self.color[1]), float(self.color[2]), float(self.color[3]))` to `glColor4d(*self.color)`

* Add `value = fn.glColor(value)`

* Remove debug print.

* Add GLGridItem and GLAxisItem

* Remove if-check for "color" argument

* Draw text without using GLUT.

* Divide the text position by the device pixel ratio

* Fixed bare exceptions to ValueError and TypeError.

* Add 'GLTextItem.py' to utils.py.

* Fixed a bare exception to ArgumentErrror.

* Add `__all__ = ['GLTextItem']`
2021-06-05 08:19:54 -07:00

36 lines
736 B
Python

# -*- coding: utf-8 -*-
"""
Simple examples demonstrating the use of GLTextItem.
"""
import initExample
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui, mkQApp
import pyqtgraph.opengl as gl
app = mkQApp("GLTextItem Example")
gvw = gl.GLViewWidget()
gvw.show()
gvw.setWindowTitle('pyqtgraph example: GLTextItem')
griditem = gl.GLGridItem()
griditem.setSize(10, 10)
griditem.setSpacing(1, 1)
gvw.addItem(griditem)
axisitem = gl.GLAxisItem()
gvw.addItem(axisitem)
txtitem1 = gl.GLTextItem(pos=(0.0, 0.0, 0.0), text='text1')
gvw.addItem(txtitem1)
txtitem2 = gl.GLTextItem()
txtitem2.setData(pos=(1.0, -1.0, 2.0), color=(127, 255, 127, 255), text='text2')
gvw.addItem(txtitem2)
if __name__ == '__main__':
pg.exec()