Commit de022be6 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Fixed Parameter 'readonly' option for bool, color, and text parameter types

parent f18f2b11
......@@ -86,6 +86,7 @@ pyqtgraph-0.9.9 [unreleased]
- Fixed TableWidget append / sort issues
- Fixed AxisItem not resizing text area when setTicks() is used
- Removed a few cyclic references
- Fixed Parameter 'readonly' option for bool, color, and text parameter types
pyqtgraph-0.9.8 2013-11-24
......
......@@ -125,6 +125,7 @@ class WidgetParameterItem(ParameterItem):
w.sigChanged = w.toggled
w.value = w.isChecked
w.setValue = w.setChecked
w.setEnabled(not opts.get('readonly', False))
self.hideWidget = False
elif t == 'str':
w = QtGui.QLineEdit()
......@@ -140,6 +141,7 @@ class WidgetParameterItem(ParameterItem):
w.setValue = w.setColor
self.hideWidget = False
w.setFlat(True)
w.setEnabled(not opts.get('readonly', False))
elif t == 'colormap':
from ..widgets.GradientWidget import GradientWidget ## need this here to avoid import loop
w = GradientWidget(orientation='bottom')
......@@ -274,6 +276,8 @@ class WidgetParameterItem(ParameterItem):
if 'readonly' in opts:
self.updateDefaultBtn()
if isinstance(self.widget, (QtGui.QCheckBox,ColorButton)):
w.setEnabled(not opts['readonly'])
## If widget is a SpinBox, pass options straight through
if isinstance(self.widget, SpinBox):
......@@ -281,6 +285,9 @@ class WidgetParameterItem(ParameterItem):
opts['suffix'] = opts['units']
self.widget.setOpts(**opts)
self.updateDisplayLabel()
class EventProxy(QtCore.QObject):
def __init__(self, qobj, callback):
......
import pyqtgraph.parametertree as pt
import pyqtgraph as pg
app = pg.mkQApp()
def test_opts():
paramSpec = [
dict(name='bool', type='bool', readonly=True),
dict(name='color', type='color', readonly=True),
]
param = pt.Parameter.create(name='params', type='group', children=paramSpec)
tree = pt.ParameterTree()
tree.setParameters(param)
assert param.param('bool').items.keys()[0].widget.isEnabled() is False
assert param.param('color').items.keys()[0].widget.isEnabled() is False
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment