pyqtgraph/examples/GradientWidget.py

55 lines
1.4 KiB
Python
Raw Normal View History

2012-05-12 00:10:48 +00:00
# -*- coding: utf-8 -*-
2013-02-25 04:09:03 +00:00
"""
Demonstrates the appearance / interactivity of GradientWidget
(without actually doing anything useful with it)
"""
2012-05-12 00:10:48 +00:00
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 = pg.mkQApp("Gradiant Widget Example")
2012-05-12 00:10:48 +00:00
w = QtGui.QMainWindow()
w.show()
2013-02-25 04:09:03 +00:00
w.setWindowTitle('pyqtgraph example: GradientWidget')
2015-01-16 16:21:33 +00:00
w.setGeometry(10, 50, 400, 400)
2012-05-12 00:10:48 +00:00
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', allowAdd=False, allowRemove=False)
2012-05-12 00:10:48 +00:00
w4 = pg.GradientWidget(orientation='left')
w4.loadPreset('spectrum')
label = QtGui.QLabel("""
- Click a triangle to change its color
- Drag triangles to move
- Right-click a gradient to load triangle presets
2012-05-12 00:10:48 +00:00
- Click in an empty area to add a new color
(adding is disabled for the bottom-side and right-side widgets)
2012-05-12 00:10:48 +00:00
- Right click a triangle to remove
(only possible if more than two triangles are visible)
(removing is disabled for the bottom-side widget)
2012-05-12 00:10:48 +00:00
""")
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)
if __name__ == '__main__':
2021-05-13 21:28:22 +00:00
pg.exec()
2012-05-12 00:10:48 +00:00