From 005160423eed35f2440afc1adebf0b3ba288a27f Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Wed, 28 Nov 2012 22:47:52 -0500 Subject: [PATCH 1/3] Converted all old-style classes to new-style for PySide compatibility. (thanks Chris) --- GraphicsScene/mouseEvents.py | 6 +++--- debug.py | 6 +++--- exceptionHandling.py | 2 +- flowchart/Terminal.py | 2 +- graphicsItems/GraphicsWidgetAnchor.py | 2 +- graphicsItems/ScatterPlotItem.py | 2 +- metaarray/MetaArray.py | 2 +- multiprocess/parallelizer.py | 4 ++-- multiprocess/remoteproxy.py | 2 +- opengl/shaders.py | 4 ++-- parametertree/Parameter.py | 2 +- pgcollections.py | 2 +- widgets/BusyCursor.py | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/GraphicsScene/mouseEvents.py b/GraphicsScene/mouseEvents.py index bb24b758..0b71ac6f 100644 --- a/GraphicsScene/mouseEvents.py +++ b/GraphicsScene/mouseEvents.py @@ -3,7 +3,7 @@ from pyqtgraph.Qt import QtCore, QtGui import weakref import pyqtgraph.ptime as ptime -class MouseDragEvent: +class MouseDragEvent(object): """ Instances of this class are delivered to items in a :class:`GraphicsScene ` via their mouseDragEvent() method when the item is being mouse-dragged. @@ -144,7 +144,7 @@ class MouseDragEvent: -class MouseClickEvent: +class MouseClickEvent(object): """ Instances of this class are delivered to items in a :class:`GraphicsScene ` via their mouseClickEvent() method when the item is clicked. @@ -229,7 +229,7 @@ class MouseClickEvent: -class HoverEvent: +class HoverEvent(object): """ Instances of this class are delivered to items in a :class:`GraphicsScene ` via their hoverEvent() method when the mouse is hovering over the item. This event class both informs items that the mouse cursor is nearby and allows items to diff --git a/debug.py b/debug.py index ba1eb4ed..ea9157aa 100644 --- a/debug.py +++ b/debug.py @@ -317,7 +317,7 @@ def objectSize(obj, ignore=None, verbose=False, depth=0, recursive=False): #print indent + ' -', k, len(refs) return size -class GarbageWatcher: +class GarbageWatcher(object): """ Convenient dictionary for holding weak references to objects. Mainly used to check whether the objects have been collect yet or not. @@ -356,7 +356,7 @@ class GarbageWatcher: return self.objs[item] -class Profiler: +class Profiler(object): """Simple profiler allowing measurement of multiple time intervals. Example: @@ -451,7 +451,7 @@ def lookup(oid, objects=None): -class ObjTracker: +class ObjTracker(object): """ Tracks all objects under the sun, reporting the changes between snapshots: what objects are created, deleted, and persistent. This class is very useful for tracking memory leaks. The class goes to great (but not heroic) lengths to avoid tracking diff --git a/exceptionHandling.py b/exceptionHandling.py index 71d538c6..daa821b7 100644 --- a/exceptionHandling.py +++ b/exceptionHandling.py @@ -47,7 +47,7 @@ def setTracebackClearing(clear=True): global clear_tracebacks clear_tracebacks = clear -class ExceptionHandler: +class ExceptionHandler(object): def __call__(self, *args): ## call original exception handler first (prints exception) global original_excepthook, callbacks, clear_tracebacks diff --git a/flowchart/Terminal.py b/flowchart/Terminal.py index 44487d04..18ff12c1 100644 --- a/flowchart/Terminal.py +++ b/flowchart/Terminal.py @@ -7,7 +7,7 @@ from pyqtgraph.Point import Point #from PySide import QtCore, QtGui from .eq import * -class Terminal: +class Terminal(object): def __init__(self, node, name, io, optional=False, multi=False, pos=None, renamable=False, removable=False, multiable=False, bypass=None): """ Construct a new terminal. diff --git a/graphicsItems/GraphicsWidgetAnchor.py b/graphicsItems/GraphicsWidgetAnchor.py index b71e781a..9770b661 100644 --- a/graphicsItems/GraphicsWidgetAnchor.py +++ b/graphicsItems/GraphicsWidgetAnchor.py @@ -2,7 +2,7 @@ from ..Qt import QtGui, QtCore from ..Point import Point -class GraphicsWidgetAnchor: +class GraphicsWidgetAnchor(object): """ Class used to allow GraphicsWidgets to anchor to a specific position on their parent. diff --git a/graphicsItems/ScatterPlotItem.py b/graphicsItems/ScatterPlotItem.py index 6e442a1d..f0dcfb60 100644 --- a/graphicsItems/ScatterPlotItem.py +++ b/graphicsItems/ScatterPlotItem.py @@ -77,7 +77,7 @@ def makeSymbolPixmap(size, pen, brush, symbol): img = renderSymbol(symbol, size, pen, brush) return QtGui.QPixmap(img) -class SymbolAtlas: +class SymbolAtlas(object): """ Used to efficiently construct a single QPixmap containing all rendered symbols for a ScatterPlotItem. This is required for fragment rendering. diff --git a/metaarray/MetaArray.py b/metaarray/MetaArray.py index 5076dd53..ec1abd3c 100644 --- a/metaarray/MetaArray.py +++ b/metaarray/MetaArray.py @@ -48,7 +48,7 @@ def axis(name=None, cols=None, values=None, units=None): ax['cols'].append(col) return ax -class sliceGenerator: +class sliceGenerator(object): """Just a compact way to generate tuples of slice objects.""" def __getitem__(self, arg): return arg diff --git a/multiprocess/parallelizer.py b/multiprocess/parallelizer.py index 96a766c1..0d5d6f5c 100644 --- a/multiprocess/parallelizer.py +++ b/multiprocess/parallelizer.py @@ -6,7 +6,7 @@ class CanceledError(Exception): """Raised when the progress dialog is canceled during a processing operation.""" pass -class Parallelize: +class Parallelize(object): """ Class for ultra-simple inline parallelization on multi-core CPUs @@ -233,7 +233,7 @@ class Parallelize: self.progress[pid].append(i) -class Tasker: +class Tasker(object): def __init__(self, parallelizer, process, tasks, kwds): self.proc = process self.par = parallelizer diff --git a/multiprocess/remoteproxy.py b/multiprocess/remoteproxy.py index 4f13b5c6..f8da1bd7 100644 --- a/multiprocess/remoteproxy.py +++ b/multiprocess/remoteproxy.py @@ -431,7 +431,7 @@ class RemoteEventHandler(object): return LocalObjectProxy(obj) -class Request: +class Request(object): """ Request objects are returned when calling an ObjectProxy in asynchronous mode or if a synchronous call has timed out. Use hasResult() to ask whether diff --git a/opengl/shaders.py b/opengl/shaders.py index e9a4af9d..1799b648 100644 --- a/opengl/shaders.py +++ b/opengl/shaders.py @@ -209,7 +209,7 @@ CompiledShaderPrograms = {} def getShaderProgram(name): return ShaderProgram.names[name] -class Shader: +class Shader(object): def __init__(self, shaderType, code): self.shaderType = shaderType self.code = code @@ -260,7 +260,7 @@ class FragmentShader(Shader): -class ShaderProgram: +class ShaderProgram(object): names = {} def __init__(self, name, shaders, uniforms=None): diff --git a/parametertree/Parameter.py b/parametertree/Parameter.py index e84bcebe..c8ed4902 100644 --- a/parametertree/Parameter.py +++ b/parametertree/Parameter.py @@ -665,7 +665,7 @@ class Parameter(QtCore.QObject): self.sigTreeStateChanged.emit(self, changes) -class SignalBlocker: +class SignalBlocker(object): def __init__(self, enterFn, exitFn): self.enterFn = enterFn self.exitFn = exitFn diff --git a/pgcollections.py b/pgcollections.py index be5281f2..b0198526 100644 --- a/pgcollections.py +++ b/pgcollections.py @@ -260,7 +260,7 @@ def makeThreadsafe(obj): raise Exception("Not sure how to make object of type %s thread-safe" % str(type(obj))) -class Locker: +class Locker(object): def __init__(self, lock): self.lock = lock self.lock.acquire() diff --git a/widgets/BusyCursor.py b/widgets/BusyCursor.py index 4212d6a6..b013dda0 100644 --- a/widgets/BusyCursor.py +++ b/widgets/BusyCursor.py @@ -2,7 +2,7 @@ from pyqtgraph.Qt import QtGui, QtCore __all__ = ['BusyCursor'] -class BusyCursor: +class BusyCursor(object): """Class for displaying a busy mouse cursor during long operations. Usage:: From d800ab03aad77bd21ca21f0dde305b4880f60a03 Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Wed, 28 Nov 2012 22:56:31 -0500 Subject: [PATCH 2/3] Added graphics item for drawing filled space between two plots --- graphicsItems/FillBetweenItem.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 graphicsItems/FillBetweenItem.py diff --git a/graphicsItems/FillBetweenItem.py b/graphicsItems/FillBetweenItem.py new file mode 100644 index 00000000..e0011177 --- /dev/null +++ b/graphicsItems/FillBetweenItem.py @@ -0,0 +1,23 @@ +import pyqtgraph as pg + +class FillBetweenItem(pg.QtGui.QGraphicsPathItem): + """ + GraphicsItem filling the space between two PlotDataItems. + """ + def __init__(self, p1, p2, brush=None): + pg.QtGui.QGraphicsPathItem.__init__(self) + self.p1 = p1 + self.p2 = p2 + p1.sigPlotChanged.connect(self.updatePath) + p2.sigPlotChanged.connect(self.updatePath) + if brush is not None: + self.setBrush(pg.mkBrush(brush)) + self.setZValue(min(p1.zValue(), p2.zValue())-1) + self.updatePath() + + def updatePath(self): + p1 = self.p1.curve.path + p2 = self.p2.curve.path + path = pg.QtGui.QPainterPath() + path.addPolygon(p1.toSubpathPolygons()[0] + p2.toReversed().toSubpathPolygons()[0]) + self.setPath(path) From 9cb199d9715986b70b765da55407f95539d1b1c7 Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Wed, 28 Nov 2012 23:34:05 -0500 Subject: [PATCH 3/3] documentation updates --- .../source/3dgraphics/glsurfaceplotitem.rst | 8 +++++ documentation/source/3dgraphics/index.rst | 3 +- documentation/source/3dgraphics/meshdata.rst | 1 - .../source/graphicsItems/fillbetweenitem.rst | 8 +++++ .../graphicsItems/graphicswidgetanchor.rst | 8 +++++ documentation/source/graphicsItems/index.rst | 2 ++ documentation/source/widgets/busycursor.rst | 8 +++++ documentation/source/widgets/combobox.rst | 8 +++++ .../source/widgets/feedbackbutton.rst | 8 +++++ documentation/source/widgets/index.rst | 9 +++++- documentation/source/widgets/layoutwidget.rst | 8 +++++ .../source/widgets/matplotlibwidget.rst | 8 +++++ documentation/source/widgets/pathbutton.rst | 8 +++++ .../source/widgets/remotegraphicsview.rst | 8 +++++ documentation/source/widgets/valuelabel.rst | 8 +++++ widgets/ValueLabel.py | 29 ++++++++++--------- 16 files changed, 116 insertions(+), 16 deletions(-) create mode 100644 documentation/source/3dgraphics/glsurfaceplotitem.rst create mode 100644 documentation/source/graphicsItems/fillbetweenitem.rst create mode 100644 documentation/source/graphicsItems/graphicswidgetanchor.rst create mode 100644 documentation/source/widgets/busycursor.rst create mode 100644 documentation/source/widgets/combobox.rst create mode 100644 documentation/source/widgets/feedbackbutton.rst create mode 100644 documentation/source/widgets/layoutwidget.rst create mode 100644 documentation/source/widgets/matplotlibwidget.rst create mode 100644 documentation/source/widgets/pathbutton.rst create mode 100644 documentation/source/widgets/remotegraphicsview.rst create mode 100644 documentation/source/widgets/valuelabel.rst diff --git a/documentation/source/3dgraphics/glsurfaceplotitem.rst b/documentation/source/3dgraphics/glsurfaceplotitem.rst new file mode 100644 index 00000000..b6f4881e --- /dev/null +++ b/documentation/source/3dgraphics/glsurfaceplotitem.rst @@ -0,0 +1,8 @@ +GLSurfacePlotItem +================= + +.. autoclass:: pyqtgraph.opengl.GLSurfacePlotItem + :members: + + .. automethod:: pyqtgraph.opengl.GLSurfacePlotItem.__init__ + diff --git a/documentation/source/3dgraphics/index.rst b/documentation/source/3dgraphics/index.rst index d569db09..255f550b 100644 --- a/documentation/source/3dgraphics/index.rst +++ b/documentation/source/3dgraphics/index.rst @@ -16,9 +16,10 @@ Contents: glviewwidget glgriditem - glmeshitem + glsurfaceplotitem glvolumeitem glimageitem + glmeshitem glaxisitem glgraphicsitem glscatterplotitem diff --git a/documentation/source/3dgraphics/meshdata.rst b/documentation/source/3dgraphics/meshdata.rst index 3e08b92e..3a79a2bb 100644 --- a/documentation/source/3dgraphics/meshdata.rst +++ b/documentation/source/3dgraphics/meshdata.rst @@ -5,5 +5,4 @@ MeshData :members: .. automethod:: pyqtgraph.opengl.MeshData.MeshData.__init__ - .. automethod:: pyqtgraph.opengl.MeshData.MeshData.__iter__ diff --git a/documentation/source/graphicsItems/fillbetweenitem.rst b/documentation/source/graphicsItems/fillbetweenitem.rst new file mode 100644 index 00000000..680f29cc --- /dev/null +++ b/documentation/source/graphicsItems/fillbetweenitem.rst @@ -0,0 +1,8 @@ +FillBetweenItem +=============== + +.. autoclass:: pyqtgraph.FillBetweenItem + :members: + + .. automethod:: pyqtgraph.FillBetweenItem.__init__ + diff --git a/documentation/source/graphicsItems/graphicswidgetanchor.rst b/documentation/source/graphicsItems/graphicswidgetanchor.rst new file mode 100644 index 00000000..e0f9d6a7 --- /dev/null +++ b/documentation/source/graphicsItems/graphicswidgetanchor.rst @@ -0,0 +1,8 @@ +GraphicsWidgetAnchor +==================== + +.. autoclass:: pyqtgraph.GraphicsWidgetAnchor + :members: + + .. automethod:: pyqtgraph.GraphicsWidgetAnchor.__init__ + diff --git a/documentation/source/graphicsItems/index.rst b/documentation/source/graphicsItems/index.rst index d618fb83..70786d20 100644 --- a/documentation/source/graphicsItems/index.rst +++ b/documentation/source/graphicsItems/index.rst @@ -23,6 +23,7 @@ Contents: axisitem textitem arrowitem + fillbetweenitem curvepoint curvearrow griditem @@ -38,4 +39,5 @@ Contents: graphicswidget graphicsitem uigraphicsitem + graphicswidgetanchor diff --git a/documentation/source/widgets/busycursor.rst b/documentation/source/widgets/busycursor.rst new file mode 100644 index 00000000..32e1977d --- /dev/null +++ b/documentation/source/widgets/busycursor.rst @@ -0,0 +1,8 @@ +BusyCursor +========== + +.. autoclass:: pyqtgraph.BusyCursor + :members: + + .. automethod:: pyqtgraph.BusyCursor.__init__ + diff --git a/documentation/source/widgets/combobox.rst b/documentation/source/widgets/combobox.rst new file mode 100644 index 00000000..9fbfd828 --- /dev/null +++ b/documentation/source/widgets/combobox.rst @@ -0,0 +1,8 @@ +ComboBox +======== + +.. autoclass:: pyqtgraph.ComboBox + :members: + + .. automethod:: pyqtgraph.ComboBox.__init__ + diff --git a/documentation/source/widgets/feedbackbutton.rst b/documentation/source/widgets/feedbackbutton.rst new file mode 100644 index 00000000..67102603 --- /dev/null +++ b/documentation/source/widgets/feedbackbutton.rst @@ -0,0 +1,8 @@ +FeedbackButton +============== + +.. autoclass:: pyqtgraph.FeedbackButton + :members: + + .. automethod:: pyqtgraph.FeedbackButton.__init__ + diff --git a/documentation/source/widgets/index.rst b/documentation/source/widgets/index.rst index bfcf34ee..913557b7 100644 --- a/documentation/source/widgets/index.rst +++ b/documentation/source/widgets/index.rst @@ -30,4 +30,11 @@ Contents: joystickbutton multiplotwidget verticallabel - + remotegraphicsview + matplotlibwidget + feedbackbutton + combobox + layoutwidget + pathbutton + valuelabel + busycursor diff --git a/documentation/source/widgets/layoutwidget.rst b/documentation/source/widgets/layoutwidget.rst new file mode 100644 index 00000000..98090a6a --- /dev/null +++ b/documentation/source/widgets/layoutwidget.rst @@ -0,0 +1,8 @@ +LayoutWidget +============ + +.. autoclass:: pyqtgraph.LayoutWidget + :members: + + .. automethod:: pyqtgraph.LayoutWidget.__init__ + diff --git a/documentation/source/widgets/matplotlibwidget.rst b/documentation/source/widgets/matplotlibwidget.rst new file mode 100644 index 00000000..1823495d --- /dev/null +++ b/documentation/source/widgets/matplotlibwidget.rst @@ -0,0 +1,8 @@ +MatplotlibWidget +================ + +.. autoclass:: pyqtgraph.widgets.MatplotlibWidget.MatplotlibWidget + :members: + + .. automethod:: pyqtgraph.widgets.MatplotlibWidget.MatplotlibWidget.__init__ + diff --git a/documentation/source/widgets/pathbutton.rst b/documentation/source/widgets/pathbutton.rst new file mode 100644 index 00000000..13298f47 --- /dev/null +++ b/documentation/source/widgets/pathbutton.rst @@ -0,0 +1,8 @@ +PathButton +========== + +.. autoclass:: pyqtgraph.PathButton + :members: + + .. automethod:: pyqtgraph.PathButton.__init__ + diff --git a/documentation/source/widgets/remotegraphicsview.rst b/documentation/source/widgets/remotegraphicsview.rst new file mode 100644 index 00000000..c6c48c25 --- /dev/null +++ b/documentation/source/widgets/remotegraphicsview.rst @@ -0,0 +1,8 @@ +RemoteGraphicsView +================== + +.. autoclass:: pyqtgraph.widgets.RemoteGraphicsView.RemoteGraphicsView + :members: + + .. automethod:: pyqtgraph.widgets.RemoteGraphicsView.RemoteGraphicsView.__init__ + diff --git a/documentation/source/widgets/valuelabel.rst b/documentation/source/widgets/valuelabel.rst new file mode 100644 index 00000000..f87a6b14 --- /dev/null +++ b/documentation/source/widgets/valuelabel.rst @@ -0,0 +1,8 @@ +ValueLabel +========== + +.. autoclass:: pyqtgraph.ValueLabel + :members: + + .. automethod:: pyqtgraph.ValueLabel.__init__ + diff --git a/widgets/ValueLabel.py b/widgets/ValueLabel.py index e32e6b14..7f6fa84b 100644 --- a/widgets/ValueLabel.py +++ b/widgets/ValueLabel.py @@ -9,22 +9,25 @@ class ValueLabel(QtGui.QLabel): """ QLabel specifically for displaying numerical values. Extends QLabel adding some extra functionality: - - displaying units with si prefix - - built-in exponential averaging + + - displaying units with si prefix + - built-in exponential averaging """ def __init__(self, parent=None, suffix='', siPrefix=False, averageTime=0, formatStr=None): """ - Arguments: - *suffix* (str or None) The suffix to place after the value - *siPrefix* (bool) Whether to add an SI prefix to the units and display a scaled value - *averageTime* (float) The length of time in seconds to average values. If this value - is 0, then no averaging is performed. As this value increases - the display value will appear to change more slowly and smoothly. - *formatStr* (str) Optionally, provide a format string to use when displaying text. The text will - be generated by calling formatStr.format(value=, avgValue=, suffix=) - (see Python documentation on str.format) - This option is not compatible with siPrefix + ============ ================================================================================== + Arguments + suffix (str or None) The suffix to place after the value + siPrefix (bool) Whether to add an SI prefix to the units and display a scaled value + averageTime (float) The length of time in seconds to average values. If this value + is 0, then no averaging is performed. As this value increases + the display value will appear to change more slowly and smoothly. + formatStr (str) Optionally, provide a format string to use when displaying text. The text + will be generated by calling formatStr.format(value=, avgValue=, suffix=) + (see Python documentation on str.format) + This option is not compatible with siPrefix + ============ ================================================================================== """ QtGui.QLabel.__init__(self, parent) self.values = [] @@ -67,4 +70,4 @@ class ValueLabel(QtGui.QLabel): return pg.siFormat(avg, suffix=self.suffix) else: return self.formatStr.format(value=val, avgValue=avg, suffix=self.suffix) - \ No newline at end of file +