Skip to content

Instantly share code, notes, and snippets.

@cpascual
Created April 21, 2017 13:34
Show Gist options
  • Save cpascual/6d4674281ee3d65f1495ff27e6e7272b to your computer and use it in GitHub Desktop.
Save cpascual/6d4674281ee3d65f1495ff27e6e7272b to your computer and use it in GitHub Desktop.
Recipe for changing curve appearance properties in a TaurusTrend
import sys
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.plot import TaurusTrend
app = TaurusApplication()
w = TaurusTrend()
model = 'sys/tg_test/1/ampli'
w.setModel(model)
#TaurusTrend uses Trendsets instead of Curves. Trendsets are collections of
# curves, but they delay the curve creation until at least one event arrives
# (in order to know how many curves are needed, depending on the data size)
# Therefore, calling w.getCurveAppearancePropertiesDict() immediately after the
# setModel returns an empty dict.
# As a workaround, one can force the app to process events before trying to get
# the curve
app.processEvents()
# after calling processEvents, we can access the curve and its properties
# Demo1 accessing via propdict (safer):
propdict = w.getCurveAppearancePropertiesDict()
propdict['sys/tg_test/1/ampli[0]'].lWidth = 9 # Note the "[0]"!!!!
w.setCurveAppearanceProperties(propdict)
# Demo2, accessing via trendset and the curve (more control, be careful with
# threads)
ts = w.getTrendSet(model)
curve = ts[0]
prop = curve.getAppearanceProperties()
prop.lColor = 'red'
curve.setAppearanceProperties(prop)
w.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment