some documentation improvements

This commit is contained in:
Megan Kratz 2016-03-25 12:36:49 -04:00
parent 240cdb1a41
commit 0e679edcf3
2 changed files with 12 additions and 6 deletions

View File

@ -25,8 +25,7 @@ Gradients = OrderedDict([
]) ])
def addGradientListToDocstring(): def addGradientListToDocstring():
### create a decorator so that we can add construct a list of the gradients defined above in a docstring """Decorator to add list of current pre-defined gradients to the end of a function docstring."""
### Adds the list of gradients to the end of the functions docstring
def dec(fn): def dec(fn):
fn.__doc__ = fn.__doc__ + str(Gradients.keys()).strip('[').strip(']') fn.__doc__ = fn.__doc__ + str(Gradients.keys()).strip('[').strip(']')
return fn return fn
@ -482,7 +481,6 @@ class GradientEditorItem(TickSliderItem):
def loadPreset(self, name): def loadPreset(self, name):
""" """
Load a predefined gradient. Currently defined gradients are: 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 #global Gradients

View File

@ -26,6 +26,7 @@ from ..graphicsItems.ROI import *
from ..graphicsItems.LinearRegionItem import * from ..graphicsItems.LinearRegionItem import *
from ..graphicsItems.InfiniteLine import * from ..graphicsItems.InfiniteLine import *
from ..graphicsItems.ViewBox import * from ..graphicsItems.ViewBox import *
from ..graphicsItems.GradientEditorItem import addGradientListToDocstring
from .. import ptime as ptime from .. import ptime as ptime
from .. import debug as debug from .. import debug as debug
from ..SignalProxy import SignalProxy from ..SignalProxy import SignalProxy
@ -719,12 +720,19 @@ class ImageView(QtGui.QWidget):
self.menu.popup(QtGui.QCursor.pos()) self.menu.popup(QtGui.QCursor.pos())
def setColorMap(self, colormap): def setColorMap(self, colormap):
"""Set the color map. *colormap* is an instance of ColorMap()""" """Set the color map.
============= =========================================================
**Arguments**
colormap (A ColorMap() instance) The ColorMap to use for coloring
images.
============= =========================================================
"""
self.ui.histogram.gradient.setColorMap(colormap) self.ui.histogram.gradient.setColorMap(colormap)
@addGradientListToDocstring()
def setPredefinedGradient(self, name): def setPredefinedGradient(self, name):
"""Set one of the gradients defined in :class:`GradientEditorItem <pyqtgraph.graphicsItems.GradientEditorItem>`. """Set one of the gradients defined in :class:`GradientEditorItem <pyqtgraph.graphicsItems.GradientEditorItem>`.
For list of available gradients see :func:`GradientEditorItem.loadPreset() <pyqtgraph.graphicsItems.GradientEditorItem.loadPreset>`. Currently available gradients are:
""" """
self.ui.histogram.gradient.loadPreset(name) self.ui.histogram.gradient.loadPreset(name)