diff --git a/CHANGELOG b/CHANGELOG index 8b6efc67..00bea8fe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ pyqtgraph-0.9.9 [unreleased] sigTransformChanged => sigDeviceTransformChanged. - GLViewWidget.itemsAt() now measures y from top of widget to match mouse event position. + - Made setPen() methods consistent throughout the package New Features: - Added ViewBox.setLimits() method diff --git a/README.md b/README.md index 2fcc7a2d..c2be3fdd 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Copyright 2012 Luke Campagnola, University of North Carolina at Chapel Hill Maintainer ---------- - * Luke Campagnola ('luke.campagnola@%s.com' % 'gmail') + * Luke Campagnola Contributors ------------ @@ -26,6 +26,7 @@ Contributors * Antony Lee * Mattias Põldaru * Thomas S. + * Mikhail Terekhov Requirements ------------ diff --git a/pyqtgraph/GraphicsScene/mouseEvents.py b/pyqtgraph/GraphicsScene/mouseEvents.py index f337a657..fa9bc36d 100644 --- a/pyqtgraph/GraphicsScene/mouseEvents.py +++ b/pyqtgraph/GraphicsScene/mouseEvents.py @@ -221,9 +221,12 @@ class MouseClickEvent(object): return self._modifiers def __repr__(self): - p = self.pos() - return "" % (p.x(), p.y(), int(self.button())) - + try: + p = self.pos() + return "" % (p.x(), p.y(), int(self.button())) + except: + return "" % (int(self.button())) + def time(self): return self._time diff --git a/pyqtgraph/flowchart/Node.py b/pyqtgraph/flowchart/Node.py index 6ae87765..fc7b04d3 100644 --- a/pyqtgraph/flowchart/Node.py +++ b/pyqtgraph/flowchart/Node.py @@ -501,8 +501,8 @@ class NodeGraphicsItem(GraphicsObject): bounds = self.boundingRect() self.nameItem.setPos(bounds.width()/2. - self.nameItem.boundingRect().width()/2., 0) - def setPen(self, pen): - self.pen = pen + def setPen(self, *args, **kwargs): + self.pen = fn.mkPen(*args, **kwargs) self.update() def setBrush(self, brush): diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py index 409ec46f..001ee2cf 100644 --- a/pyqtgraph/graphicsItems/AxisItem.py +++ b/pyqtgraph/graphicsItems/AxisItem.py @@ -74,7 +74,10 @@ class AxisItem(GraphicsWidget): self.setRange(0, 1) - self.setPen(pen) + if pen is None: + self.setPen() + else: + self.setPen(pen) self._linkedView = None if linkView is not None: @@ -271,16 +274,17 @@ class AxisItem(GraphicsWidget): return fn.mkPen(getConfigOption('foreground')) return fn.mkPen(self._pen) - def setPen(self, pen): + def setPen(self, *args, **kwargs): """ Set the pen used for drawing text, axes, ticks, and grid lines. - if pen == None, the default will be used (see :func:`setConfigOption - `) + If no arguments are given, the default foreground color will be used + (see :func:`setConfigOption `). """ self.picture = None - if pen is None: - pen = getConfigOption('foreground') - self._pen = fn.mkPen(pen) + if args or kwargs: + self._pen = fn.mkPen(*args, **kwargs) + else: + self._pen = fn.mkPen(getConfigOption('foreground')) self.labelStyle['color'] = '#' + fn.colorStr(self._pen.color())[:6] self.setLabel() self.update() diff --git a/pyqtgraph/graphicsItems/GraphItem.py b/pyqtgraph/graphicsItems/GraphItem.py index 6860790c..413fd79a 100644 --- a/pyqtgraph/graphicsItems/GraphItem.py +++ b/pyqtgraph/graphicsItems/GraphItem.py @@ -28,7 +28,7 @@ class GraphItem(GraphicsObject): """ Change the data displayed by the graph. - ============== ========================================================= + ============== ======================================================================= **Arguments:** pos (N,2) array of the positions of each node in the graph. adj (M,2) array of connection data. Each row contains indexes @@ -50,7 +50,7 @@ class GraphItem(GraphicsObject): :func:`ScatterPlotItem.setData() ` to affect the appearance of nodes (symbol, size, brush, etc.) - ============== ========================================================= + ============== ======================================================================= """ if 'adj' in kwds: self.adjacency = kwds.pop('adj') @@ -67,8 +67,21 @@ class GraphItem(GraphicsObject): self.scatter.setData(**kwds) self.informViewBoundsChanged() - def setPen(self, pen): - self.pen = pen + def setPen(self, *args, **kwargs): + """ + Set the pen used to draw graph lines. + May be: + + * None to disable line drawing + * Record array with fields (red, green, blue, alpha, width) + * Any set of arguments and keyword arguments accepted by + :func:`mkPen `. + * 'default' to use the default foreground color. + """ + if len(args) == 1 and len(kwargs) == 0: + self.pen = args[0] + else: + self.pen = fn.mkPen(*args, **kwargs) self.picture = None def generatePicture(self): diff --git a/pyqtgraph/graphicsItems/InfiniteLine.py b/pyqtgraph/graphicsItems/InfiniteLine.py index 08a55f83..dfe2a4c1 100644 --- a/pyqtgraph/graphicsItems/InfiniteLine.py +++ b/pyqtgraph/graphicsItems/InfiniteLine.py @@ -73,10 +73,10 @@ class InfiniteLine(GraphicsObject): self.maxRange = bounds self.setValue(self.value()) - def setPen(self, pen): + def setPen(self, *args, **kwargs): """Set the pen for drawing the line. Allowable arguments are any that are valid for :func:`mkPen `.""" - self.pen = fn.mkPen(pen) + self.pen = fn.mkPen(*args, **kwargs) self.currentPen = self.pen self.update() diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py index 2f04a164..c0f9008c 100644 --- a/pyqtgraph/graphicsItems/ROI.py +++ b/pyqtgraph/graphicsItems/ROI.py @@ -194,11 +194,12 @@ class ROI(GraphicsObject): """ return self.mapToParent(self.boundingRect()).boundingRect() - def setPen(self, pen): + def setPen(self, *args, **kwargs): """ - Set the pen to use when drawing the ROI shape. + Set the pen to use when drawing the ROI shape. + For arguments, see :func:`mkPen `. """ - self.pen = fn.mkPen(pen) + self.pen = fn.mkPen(*args, **kwargs) self.currentPen = self.pen self.update() diff --git a/pyqtgraph/widgets/PathButton.py b/pyqtgraph/widgets/PathButton.py index 0c62bb1b..52c60e20 100644 --- a/pyqtgraph/widgets/PathButton.py +++ b/pyqtgraph/widgets/PathButton.py @@ -23,8 +23,8 @@ class PathButton(QtGui.QPushButton): def setBrush(self, brush): self.brush = fn.mkBrush(brush) - def setPen(self, pen): - self.pen = fn.mkPen(pen) + def setPen(self, *args, **kwargs): + self.pen = fn.mkPen(*args, **kwargs) def setPath(self, path): self.path = path @@ -46,6 +46,5 @@ class PathButton(QtGui.QPushButton): p.setBrush(self.brush) p.drawPath(self.path) p.end() - + - \ No newline at end of file