Fixed Parameter 'readonly' option for bool, color, and text parameter types
This commit is contained in:
parent
f18f2b11c8
commit
de022be634
@ -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):
|
||||
|
18
pyqtgraph/parametertree/tests/test_parametertypes.py
Normal file
18
pyqtgraph/parametertree/tests/test_parametertypes.py
Normal file
@ -0,0 +1,18 @@
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user