2011-04-05 16:53:05 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-03-17 15:47:20 +00:00
|
|
|
|
|
|
|
## Display an animated arrowhead following a curve.
|
|
|
|
## This example uses the CurveArrow class, which is a combination
|
|
|
|
## of ArrowItem and CurvePoint.
|
|
|
|
##
|
|
|
|
## To place a static arrow anywhere in a scene, use ArrowItem.
|
|
|
|
## To attach other types of item to a curve, use CurvePoint.
|
|
|
|
|
|
|
|
|
2012-03-02 02:55:32 +00:00
|
|
|
## Add path to library (just for examples; you do not need this)
|
2012-03-17 15:47:20 +00:00
|
|
|
import initExample ## Add path to library (just for examples; you do not need this)
|
2011-04-05 16:53:05 +00:00
|
|
|
|
|
|
|
import numpy as np
|
2012-03-02 03:53:52 +00:00
|
|
|
from pyqtgraph.Qt import QtGui, QtCore
|
2011-04-05 16:53:05 +00:00
|
|
|
import pyqtgraph as pg
|
|
|
|
|
|
|
|
|
|
|
|
app = QtGui.QApplication([])
|
|
|
|
mw = QtGui.QMainWindow()
|
2012-03-12 16:23:25 +00:00
|
|
|
mw.resize(300,300)
|
2011-04-05 16:53:05 +00:00
|
|
|
|
|
|
|
p = pg.PlotWidget()
|
|
|
|
mw.setCentralWidget(p)
|
2012-03-02 02:55:32 +00:00
|
|
|
c = p.plot(x=np.sin(np.linspace(0, 2*np.pi, 1000)), y=np.cos(np.linspace(0, 6*np.pi, 1000)))
|
2011-04-05 16:53:05 +00:00
|
|
|
a = pg.CurveArrow(c)
|
|
|
|
p.addItem(a)
|
|
|
|
|
|
|
|
mw.show()
|
|
|
|
|
|
|
|
anim = a.makeAnimation(loop=-1)
|
|
|
|
anim.start()
|
|
|
|
|
2012-03-17 15:47:20 +00:00
|
|
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
2012-03-23 07:21:04 +00:00
|
|
|
import sys
|
2012-03-17 15:47:20 +00:00
|
|
|
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
2011-04-05 16:53:05 +00:00
|
|
|
app.exec_()
|