Deprecate values opt for list parameter

This commit is contained in:
Nathan Jessurun 2021-08-05 15:28:05 -04:00
parent f16125c378
commit 6f44d27f2d
4 changed files with 9 additions and 6 deletions

View File

@ -66,8 +66,8 @@ params = [
{'name': 'Integer', 'type': 'int', 'value': 10}, {'name': 'Integer', 'type': 'int', 'value': 10},
{'name': 'Float', 'type': 'float', 'value': 10.5, 'step': 0.1, 'finite': False}, {'name': 'Float', 'type': 'float', 'value': 10.5, 'step': 0.1, 'finite': False},
{'name': 'String', 'type': 'str', 'value': "hi", 'tip': 'Well hello'}, {'name': 'String', 'type': 'str', 'value': "hi", 'tip': 'Well hello'},
{'name': 'List', 'type': 'list', 'values': [1,2,3], 'value': 2}, {'name': 'List', 'type': 'list', 'limits': [1,2,3], 'value': 2},
{'name': 'Named List', 'type': 'list', 'values': {"one": 1, "two": "twosies", "three": [3,3,3]}, 'value': 2}, {'name': 'Named List', 'type': 'list', 'limits': {"one": 1, "two": "twosies", "three": [3,3,3]}, 'value': 2},
{'name': 'Boolean', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"}, {'name': 'Boolean', 'type': 'bool', 'value': True, 'tip': "This is a checkbox"},
{'name': 'Color', 'type': 'color', 'value': "#FF0", 'tip': "This is a color button"}, {'name': 'Color', 'type': 'color', 'value': "#FF0", 'tip': "This is a color button"},
{'name': 'Gradient', 'type': 'colormap'}, {'name': 'Gradient', 'type': 'colormap'},

View File

@ -15,9 +15,9 @@ class CSVExporter(Exporter):
def __init__(self, item): def __init__(self, item):
Exporter.__init__(self, item) Exporter.__init__(self, item)
self.params = Parameter(name='params', type='group', children=[ self.params = Parameter(name='params', type='group', children=[
{'name': 'separator', 'title': translate("Exporter", 'separator'), 'type': 'list', 'value': 'comma', 'values': ['comma', 'tab']}, {'name': 'separator', 'title': translate("Exporter", 'separator'), 'type': 'list', 'value': 'comma', 'limits': ['comma', 'tab']},
{'name': 'precision', 'title': translate("Exporter", 'precision'), 'type': 'int', 'value': 10, 'limits': [0, None]}, {'name': 'precision', 'title': translate("Exporter", 'precision'), 'type': 'int', 'value': 10, 'limits': [0, None]},
{'name': 'columnMode', 'title': translate("Exporter", 'columnMode'), 'type': 'list', 'values': ['(x,y) per plot', '(x,y,y,y) for all plots']} {'name': 'columnMode', 'title': translate("Exporter", 'columnMode'), 'type': 'list', 'limits': ['(x,y) per plot', '(x,y,y,y) for all plots']}
]) ])
def parameters(self): def parameters(self):

View File

@ -26,7 +26,7 @@ class HDF5Exporter(Exporter):
self.params = Parameter(name='params', type='group', children=[ self.params = Parameter(name='params', type='group', children=[
{'name': 'Name', 'title': translate("Exporter", 'Name'), 'type': 'str', 'value': 'Export', }, {'name': 'Name', 'title': translate("Exporter", 'Name'), 'type': 'str', 'value': 'Export', },
{'name': 'columnMode', 'title': translate("Exporter", 'columnMode'), 'type': 'list', {'name': 'columnMode', 'title': translate("Exporter", 'columnMode'), 'type': 'list',
'values': ['(x,y) per plot', '(x,y,y,y) for all plots']}, 'limits': ['(x,y) per plot', '(x,y,y,y) for all plots']},
]) ])
def parameters(self): def parameters(self):

View File

@ -1,3 +1,4 @@
import warnings
from collections import OrderedDict from collections import OrderedDict
from .basetypes import WidgetParameterItem from .basetypes import WidgetParameterItem
@ -74,7 +75,7 @@ class ListParameter(Parameter):
In addition to the generic :class:`~pyqtgraph.parametertree.Parameter` In addition to the generic :class:`~pyqtgraph.parametertree.Parameter`
options, this parameter type accepts a ``limits`` argument specifying the options, this parameter type accepts a ``limits`` argument specifying the
list of allowed values. ``values`` is an alias and may be used instead. list of allowed values.
The values may generally be of any data type, as long as they can be The values may generally be of any data type, as long as they can be
represented as a string. If the string representation provided is represented as a string. If the string representation provided is
@ -90,6 +91,8 @@ class ListParameter(Parameter):
# Parameter uses 'limits' option to define the set of allowed values # Parameter uses 'limits' option to define the set of allowed values
if 'values' in opts: if 'values' in opts:
warnings.warn('Using "values" to set limits is deprecated and will be removed in 0.13. Use "limits"'
' instead.', DeprecationWarning, stacklevel=2)
opts['limits'] = opts['values'] opts['limits'] = opts['values']
if opts.get('limits', None) is None: if opts.get('limits', None) is None:
opts['limits'] = [] opts['limits'] = []