From 8a9557cff1a58f5d7a1f048e3fb1070310769161 Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Fri, 11 May 2012 20:10:48 -0400 Subject: [PATCH] added GradientWidget example --- examples/GradientWidget.py | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 examples/GradientWidget.py diff --git a/examples/GradientWidget.py b/examples/GradientWidget.py new file mode 100644 index 00000000..3f9566a2 --- /dev/null +++ b/examples/GradientWidget.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +import initExample ## Add path to library (just for examples; you do not need this) + +import pyqtgraph as pg +from pyqtgraph.Qt import QtCore, QtGui +import numpy as np + + + +app = QtGui.QApplication([]) +w = QtGui.QMainWindow() +w.show() +w.resize(400,400) +cw = QtGui.QWidget() +w.setCentralWidget(cw) + +l = QtGui.QGridLayout() +l.setSpacing(0) +cw.setLayout(l) + +w1 = pg.GradientWidget(orientation='top') +w2 = pg.GradientWidget(orientation='right', allowAdd=False) +#w2.setTickColor(1, QtGui.QColor(255,255,255)) +w3 = pg.GradientWidget(orientation='bottom') +w4 = pg.GradientWidget(orientation='left') +w4.loadPreset('spectrum') +label = QtGui.QLabel(""" +- Click a triangle to change its color +- Drag triangles to move +- Click in an empty area to add a new color + (adding is disabled for the right-side widget) +- Right click a triangle to remove +""") + +l.addWidget(w1, 0, 1) +l.addWidget(w2, 1, 2) +l.addWidget(w3, 2, 1) +l.addWidget(w4, 1, 0) +l.addWidget(label, 1, 1) + + +## Start Qt event loop unless running in interactive mode or using pyside. +import sys +if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): + QtGui.QApplication.instance().exec_() + + +