From 727214ca45609aadf46027184bd537e2893fff44 Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Sun, 15 Apr 2012 10:20:07 -0400 Subject: [PATCH] docstring updates --- graphicsItems/PlotItem/PlotItem.py | 24 ++++++++++++++++++++---- widgets/PlotWidget.py | 20 ++++++++++---------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/graphicsItems/PlotItem/PlotItem.py b/graphicsItems/PlotItem/PlotItem.py index b9fcff5a..cc0bac8c 100644 --- a/graphicsItems/PlotItem/PlotItem.py +++ b/graphicsItems/PlotItem/PlotItem.py @@ -59,7 +59,20 @@ class PlotItem(GraphicsWidget): sigXRangeChanged = QtCore.Signal(object, object) sigRangeChanged = QtCore.Signal(object, object) - """Plot graphics item that can be added to any graphics scene. Implements axis titles, scales, interactive viewbox.""" + """ + Plot graphics item that can be added to any graphics scene. Implements axis titles, scales, interactive viewbox. + + Use plot(...) to create a new PlotDataItem and add it to the view. + Use addItem(...) add any QGraphicsItem to the view + + This class wraps several methods from its internal ViewBox: + setXRange, setYRange, setXLink, setYLink, + setRange, autoRange, viewRect, setMouseEnabled, + enableAutoRange, disableAutoRange, setAspectLocked, + register, unregister. + + The ViewBox itself can be accessed by calling getVewBox() + """ lastFileDir = None managers = {} @@ -76,6 +89,8 @@ class PlotItem(GraphicsWidget): Optionally, PlotItem my also be initialized with the keyword arguments left, right, top, or bottom to achieve the same effect. *name* - Registers a name for this view so that others may link to it + + """ GraphicsWidget.__init__(self, parent) @@ -289,6 +304,7 @@ class PlotItem(GraphicsWidget): return interface in ['ViewBoxWrapper'] def getViewBox(self): + """Return the ViewBox within.""" return self.vb @@ -346,7 +362,7 @@ class PlotItem(GraphicsWidget): #else: #print "no manager" - def registerPlot(self, name): + def registerPlot(self, name): ## for backward compatibility self.vb.register(name) #self.name = name #win = str(self.window()) @@ -398,7 +414,7 @@ class PlotItem(GraphicsWidget): self.scales[k]['item'].setGrid(g) def viewGeometry(self): - """return the screen geometry of the viewbox""" + """Return the screen geometry of the viewbox""" v = self.scene().views()[0] b = self.vb.mapRectToScene(self.vb.boundingRect()) wr = v.mapFromScene(b).boundingRect() @@ -514,7 +530,7 @@ class PlotItem(GraphicsWidget): self.replot() def addAvgCurve(self, curve): - """Add a single curve into the pool of curves averaged together""" + ## Add a single curve into the pool of curves averaged together ## If there are plot parameters, then we need to determine which to average together. remKeys = [] diff --git a/widgets/PlotWidget.py b/widgets/PlotWidget.py index 807e609f..fa9fcf1a 100644 --- a/widgets/PlotWidget.py +++ b/widgets/PlotWidget.py @@ -15,7 +15,13 @@ class PlotWidget(GraphicsView): #sigRangeChanged = QtCore.Signal(object, object) ## already defined in GraphicsView - """Widget implementing a graphicsView with a single PlotItem inside.""" + """ + Widget implementing a graphicsView with a single PlotItem inside. + + The following methods are wrapped directly from PlotItem: addItem, removeItem, + clear, setXRange, setYRange, setRange, setAspectLocked, setMouseEnabled. For all + other methods, use getPlotItem. + """ def __init__(self, parent=None, **kargs): GraphicsView.__init__(self, parent) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) @@ -27,14 +33,7 @@ class PlotWidget(GraphicsView): setattr(self, m, getattr(self.plotItem, m)) #QtCore.QObject.connect(self.plotItem, QtCore.SIGNAL('viewChanged'), self.viewChanged) self.plotItem.sigRangeChanged.connect(self.viewRangeChanged) - - #def __dtor__(self): - ##print "Called plotWidget sip destructor" - #self.quit() - - - #def quit(self): - + def close(self): self.plotItem.close() self.plotItem = None @@ -49,7 +48,7 @@ class PlotWidget(GraphicsView): if hasattr(m, '__call__'): return m raise exceptions.NameError(attr) - + def viewRangeChanged(self, view, range): #self.emit(QtCore.SIGNAL('viewChanged'), *args) self.sigRangeChanged.emit(self, range) @@ -64,6 +63,7 @@ class PlotWidget(GraphicsView): return self.plotItem.restoreState(state) def getPlotItem(self): + """Return the PlotItem contained within.""" return self.plotItem