You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to set a CurveArrow item as parent of a TextItem, as in "Text.py" example (in Text.py it's a CurvePoint that is use as a parent of TextItem). So I have tried for a first time to modify CurveArrow in CurvePoint.py by adding a TextItem, but the text wasn't displaying, so I put the modification in my copy of the example and putting in comment the modification I made.
Code to reproduce
in CurvePoint.py :
importweakreffrommathimportatan2, degreesfrom ..functionsimportclip_scalarfrom ..QtimportQtCore, QtWidgetsfrom . importArrowItem, TextItem, LabelItemfrom .GraphicsObjectimportGraphicsObject
...
classCurveArrow(CurvePoint):
"""Provides an arrow that points to any specific sample on a PlotCurveItem. Provides properties that can be animated."""def__init__(self, curve, index=0, rotate=True, pos=None, **opts):
CurvePoint.__init__(self, curve, index=index, pos=pos, rotate=rotate)
ifopts.get('pxMode', True):
opts['pxMode'] =Falseself.setFlags(self.flags() |self.GraphicsItemFlag.ItemIgnoresTransformations)
# opts['angle'] = 0# self.Text = TextItem.TextItem("Test", anchor=(0.5, -1.0))# self.Text.setParentItem(self)self.arrow=ArrowItem.ArrowItem(**opts)
self.arrow.setParentItem(self)
# print(self.Text)defsetStyle(self, **opts):
returnself.arrow.setStyle(**opts)
in TestText.py :
importnumpyasnpimportpyqtgraphaspgfrompyqtgraph.QtimportQtCorex=np.linspace(-20, 20, 1000)
y=np.sin(x) /xplot=pg.plot() ## create an empty plot widgetplot.setYRange(-1, 2)
plot.setWindowTitle('pyqtgraph example: text')
curve=plot.plot(x,y) ## add a single curve# Create an animated arrow (cursor) that track the curve curvePoint=pg.CurveArrow(curve, rotate=False, angle=90)
plot.addItem(curvePoint)
# Configure the TextItemText=pg.TextItem("test", anchor=(0.5, -1.0))
Text.setParentItem(curvePoint)
## update position every 10msindex=0defupdate():
globalcurvePoint, indexindex= (index+1) %len(x)
curvePoint.setPos(float(index)/(len(x)-1))
# text2.setText('[%0.1f, %0.1f]' % (x[index], y[index]))# curvePoint.Text('[%0.1f, %0.1f]' % (x[index], y[index]))Text.setText('[%0.1f, %0.1f]'% (x[index], y[index]))
timer=QtCore.QTimer()
timer.timeout.connect(update)
timer.start(10)
if__name__=='__main__':
pg.exec()
Expected behavior
I should have the same behavior as the example "Text.py", so an arrow and a text that are animated and follow the sinc(x).
Real behavior
I have the arrow that is animated and follows the curve, but I don't have any text that notifies me about the position of the arrow on the curve. Additionally, I'm using this example to identify an error in one of my scripts: It's a simple script that adds a CurveArrow to a curve. I encountered this error while using the modified CurveArrow. :
QWinFontEngine: unable to query transformed glyph metrics (GetGlyphOutline() failed, error 1003)... (Impossible dÆaccomplir cette fonction.)
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::setCompositionMode: Painter not active
QPainter::end: Painter not active, aborted
Tested environment(s)
PyQtGraph version: <0.13.3>
Qt Python binding: <PyQt5 5.15.4 Qt 5.15.2>
Python version: Python 3.10.6
NumPy version: <1.24.2>
Operating system: Windows 11
Installation method: pip
Additional context
I thank you in advance for any help
Edit1 : I forgot to tell that I add the argument "rotate" with default value "True" and put the line "opts['angle'] = 0" as I wanted to have something like CurvePoint.
The text was updated successfully, but these errors were encountered:
Short description
I'm trying to set a CurveArrow item as parent of a TextItem, as in "Text.py" example (in Text.py it's a CurvePoint that is use as a parent of TextItem). So I have tried for a first time to modify CurveArrow in CurvePoint.py by adding a TextItem, but the text wasn't displaying, so I put the modification in my copy of the example and putting in comment the modification I made.
Code to reproduce
in CurvePoint.py :
in TestText.py :
Expected behavior
I should have the same behavior as the example "Text.py", so an arrow and a text that are animated and follow the sinc(x).
Real behavior
I have the arrow that is animated and follows the curve, but I don't have any text that notifies me about the position of the arrow on the curve. Additionally, I'm using this example to identify an error in one of my scripts: It's a simple script that adds a CurveArrow to a curve. I encountered this error while using the modified CurveArrow. :
Tested environment(s)
Additional context
I thank you in advance for any help
Edit1 : I forgot to tell that I add the argument "rotate" with default value "True" and put the line "opts['angle'] = 0" as I wanted to have something like CurvePoint.
The text was updated successfully, but these errors were encountered: