Add Deprecation Warning to Hex Strings That Do Not Start With "#" in mkColor (#1644)
* Add deprecation warning * Incorporate changes to docs/warning * correct input for no warnings * Update docs examples in LabelItem
This commit is contained in:
parent
4951bd743e
commit
bb5a179647
@ -42,7 +42,7 @@ class CustomTickSliderItem(pg.TickSliderItem):
|
|||||||
self.removeTick(tick)
|
self.removeTick(tick)
|
||||||
|
|
||||||
for pos in ticks:
|
for pos in ticks:
|
||||||
tickItem = self.addTick(pos, movable=False, color="333333")
|
tickItem = self.addTick(pos, movable=False, color="#333333")
|
||||||
self.all_ticks[pos] = tickItem
|
self.all_ticks[pos] = tickItem
|
||||||
|
|
||||||
self.updateRange(None, self._range)
|
self.updateRange(None, self._range)
|
||||||
|
@ -69,7 +69,7 @@ params = [
|
|||||||
{'name': 'List', 'type': 'list', 'values': [1,2,3], 'value': 2},
|
{'name': 'List', 'type': 'list', 'values': [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', 'values': {"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'},
|
||||||
{'name': 'Subgroup', 'type': 'group', 'children': [
|
{'name': 'Subgroup', 'type': 'group', 'children': [
|
||||||
{'name': 'Sub-param 1', 'type': 'int', 'value': 10},
|
{'name': 'Sub-param 1', 'type': 'int', 'value': 10},
|
||||||
|
@ -213,7 +213,8 @@ class Color(QtGui.QColor):
|
|||||||
|
|
||||||
def mkColor(*args):
|
def mkColor(*args):
|
||||||
"""
|
"""
|
||||||
Convenience function for constructing QColor from a variety of argument types. Accepted arguments are:
|
Convenience function for constructing QColor from a variety of argument
|
||||||
|
types. Accepted arguments are:
|
||||||
|
|
||||||
================ ================================================
|
================ ================================================
|
||||||
'c' one of: r, g, b, c, m, y, k, w
|
'c' one of: r, g, b, c, m, y, k, w
|
||||||
@ -222,10 +223,10 @@ def mkColor(*args):
|
|||||||
float greyscale, 0.0-1.0
|
float greyscale, 0.0-1.0
|
||||||
int see :func:`intColor() <pyqtgraph.intColor>`
|
int see :func:`intColor() <pyqtgraph.intColor>`
|
||||||
(int, hues) see :func:`intColor() <pyqtgraph.intColor>`
|
(int, hues) see :func:`intColor() <pyqtgraph.intColor>`
|
||||||
"RGB" hexadecimal strings; may begin with '#'
|
"#RGB" hexadecimal strings prefixed with '#'
|
||||||
"RGBA"
|
"#RGBA" previously allowed use without prefix is deprecated and
|
||||||
"RRGGBB"
|
"#RRGGBB" will be removed in 0.13
|
||||||
"RRGGBBAA"
|
"#RRGGBBAA"
|
||||||
QColor QColor instance; makes a copy.
|
QColor QColor instance; makes a copy.
|
||||||
================ ================================================
|
================ ================================================
|
||||||
"""
|
"""
|
||||||
@ -233,13 +234,19 @@ def mkColor(*args):
|
|||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
if isinstance(args[0], basestring):
|
if isinstance(args[0], basestring):
|
||||||
c = args[0]
|
c = args[0]
|
||||||
if c[0] == '#':
|
|
||||||
c = c[1:]
|
|
||||||
if len(c) == 1:
|
if len(c) == 1:
|
||||||
try:
|
try:
|
||||||
return Colors[c]
|
return Colors[c]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise ValueError('No color named "%s"' % c)
|
raise ValueError('No color named "%s"' % c)
|
||||||
|
if c[0] == '#':
|
||||||
|
c = c[1:]
|
||||||
|
else:
|
||||||
|
warnings.warn(
|
||||||
|
"Parsing of hex strings that do not start with '#' is"
|
||||||
|
"deprecated and support will be removed in 0.13",
|
||||||
|
DeprecationWarning, stacklevel=2
|
||||||
|
)
|
||||||
if len(c) == 3:
|
if len(c) == 3:
|
||||||
r = int(c[0]*2, 16)
|
r = int(c[0]*2, 16)
|
||||||
g = int(c[1]*2, 16)
|
g = int(c[1]*2, 16)
|
||||||
|
@ -39,7 +39,7 @@ class LabelItem(GraphicsWidget, GraphicsWidgetAnchor):
|
|||||||
|
|
||||||
==================== ==============================
|
==================== ==============================
|
||||||
**Style Arguments:**
|
**Style Arguments:**
|
||||||
color (str) example: 'CCFF00'
|
color (str) example: '#CCFF00'
|
||||||
size (str) example: '8pt'
|
size (str) example: '8pt'
|
||||||
bold (bool)
|
bold (bool)
|
||||||
italic (bool)
|
italic (bool)
|
||||||
|
@ -46,7 +46,7 @@ def test_types():
|
|||||||
all_objs = {
|
all_objs = {
|
||||||
'int0': 0, 'int':7, 'float': -0.35, 'bigfloat': 1e129, 'npfloat': np.float64(5),
|
'int0': 0, 'int':7, 'float': -0.35, 'bigfloat': 1e129, 'npfloat': np.float64(5),
|
||||||
'npint': np.int64(5),'npinf': np.inf, 'npnan': np.nan, 'bool': True,
|
'npint': np.int64(5),'npinf': np.inf, 'npnan': np.nan, 'bool': True,
|
||||||
'complex': 5+3j, 'str': 'xxx', 'unicode': asUnicode('µ'),
|
'complex': 5+3j, 'str': '#xxx', 'unicode': asUnicode('µ'),
|
||||||
'list': [1,2,3], 'dict': {'1': 2}, 'color': pg.mkColor('k'),
|
'list': [1,2,3], 'dict': {'1': 2}, 'color': pg.mkColor('k'),
|
||||||
'brush': pg.mkBrush('k'), 'pen': pg.mkPen('k'), 'none': None
|
'brush': pg.mkBrush('k'), 'pen': pg.mkPen('k'), 'none': None
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user