created a decorator function so we can auto-add the list of defined Gradients to docstrings
This commit is contained in:
parent
e5bd1f51a8
commit
e418645502
|
@ -13,7 +13,6 @@ from ..python2_3 import cmp
|
|||
|
||||
__all__ = ['TickSliderItem', 'GradientEditorItem']
|
||||
|
||||
##### If Gradients are added or removed, or gradient names are changed, please update the GradientEditorItem.loadPreset docstring.
|
||||
Gradients = OrderedDict([
|
||||
('thermal', {'ticks': [(0.3333, (185, 0, 0, 255)), (0.6666, (255, 220, 0, 255)), (1, (255, 255, 255, 255)), (0, (0, 0, 0, 255))], 'mode': 'rgb'}),
|
||||
('flame', {'ticks': [(0.2, (7, 0, 220, 255)), (0.5, (236, 0, 134, 255)), (0.8, (246, 246, 0, 255)), (1.0, (255, 255, 255, 255)), (0.0, (0, 0, 0, 255))], 'mode': 'rgb'}),
|
||||
|
@ -25,6 +24,14 @@ Gradients = OrderedDict([
|
|||
('grey', {'ticks': [(0.0, (0, 0, 0, 255)), (1.0, (255, 255, 255, 255))], 'mode': 'rgb'}),
|
||||
])
|
||||
|
||||
def addGradientListToDocstring():
|
||||
### create a decorator so that we can add construct a list of the gradients defined above in a docstring
|
||||
### Adds the list of gradients to the end of the functions docstring
|
||||
def dec(fn):
|
||||
fn.__doc__ = fn.__doc__ + str(Gradients.keys()).strip('[').strip(']')
|
||||
return fn
|
||||
return dec
|
||||
|
||||
|
||||
|
||||
class TickSliderItem(GraphicsWidget):
|
||||
|
@ -471,12 +478,13 @@ class GradientEditorItem(TickSliderItem):
|
|||
act = self.sender()
|
||||
self.loadPreset(act.name)
|
||||
|
||||
@addGradientListToDocstring()
|
||||
def loadPreset(self, name):
|
||||
"""
|
||||
Load a predefined gradient. Currently defined gradients are: 'thermal',
|
||||
'flame', 'yellowy', 'bipolar', 'spectrum', 'cyclic', 'greyclip', and 'grey'.
|
||||
Load a predefined gradient. Currently defined gradients are:
|
||||
|
||||
""" ## TODO: provide image with names of defined gradients
|
||||
"""## TODO: provide image with names of defined gradients
|
||||
|
||||
#global Gradients
|
||||
self.restoreState(Gradients[name])
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user