From f6307344534c309b44c285398e0d34053af67a99 Mon Sep 17 00:00:00 2001
From: Luke Campagnola <luke.campagnola@gmail.com>
Date: Sun, 22 Dec 2013 02:08:39 -0500
Subject: [PATCH] Switching to relative imports to allow pyqtgraph to be
 imported under other names.

finished top-level files and graphicsItems
---
 pyqtgraph/SRTTransform.py                     |  5 ++--
 pyqtgraph/SRTTransform3D.py                   | 26 +++++++++----------
 pyqtgraph/ThreadsafeTimer.py                  |  2 +-
 pyqtgraph/Transform3D.py                      |  4 +--
 pyqtgraph/colormap.py                         |  2 +-
 pyqtgraph/functions.py                        | 14 +++++-----
 pyqtgraph/graphicsItems/ArrowItem.py          |  4 +--
 pyqtgraph/graphicsItems/AxisItem.py           | 20 +++++++-------
 pyqtgraph/graphicsItems/BarGraphItem.py       | 16 +++++++-----
 pyqtgraph/graphicsItems/ButtonItem.py         |  2 +-
 pyqtgraph/graphicsItems/CurvePoint.py         |  4 +--
 pyqtgraph/graphicsItems/ErrorBarItem.py       |  9 ++++---
 pyqtgraph/graphicsItems/FillBetweenItem.py    | 11 ++++----
 pyqtgraph/graphicsItems/GradientEditorItem.py | 10 +++----
 pyqtgraph/graphicsItems/GradientLegend.py     |  4 +--
 pyqtgraph/graphicsItems/GraphItem.py          | 18 ++++++-------
 pyqtgraph/graphicsItems/GraphicsItem.py       | 10 +++----
 pyqtgraph/graphicsItems/GraphicsLayout.py     |  4 +--
 pyqtgraph/graphicsItems/GraphicsObject.py     |  2 +-
 pyqtgraph/graphicsItems/GraphicsWidget.py     |  4 +--
 pyqtgraph/graphicsItems/GridItem.py           |  6 ++---
 pyqtgraph/graphicsItems/HistogramLUTItem.py   | 10 +++----
 pyqtgraph/graphicsItems/ImageItem.py          |  6 ++---
 pyqtgraph/graphicsItems/InfiniteLine.py       |  6 ++---
 pyqtgraph/graphicsItems/IsocurveItem.py       |  4 +--
 pyqtgraph/graphicsItems/ItemGroup.py          |  2 +-
 pyqtgraph/graphicsItems/LabelItem.py          |  8 +++---
 pyqtgraph/graphicsItems/LegendItem.py         | 13 +++++-----
 pyqtgraph/graphicsItems/LinearRegionItem.py   |  6 ++---
 pyqtgraph/graphicsItems/PlotCurveItem.py      | 18 ++++++-------
 pyqtgraph/graphicsItems/PlotDataItem.py       | 12 ++++-----
 pyqtgraph/graphicsItems/ROI.py                |  8 +++---
 pyqtgraph/graphicsItems/ScaleBar.py           |  8 +++---
 pyqtgraph/graphicsItems/ScatterPlotItem.py    | 18 ++++++-------
 pyqtgraph/graphicsItems/TextItem.py           | 16 ++++++------
 pyqtgraph/graphicsItems/UIGraphicsItem.py     |  2 +-
 pyqtgraph/graphicsItems/VTickGroup.py         | 18 ++-----------
 37 files changed, 161 insertions(+), 171 deletions(-)

diff --git a/pyqtgraph/SRTTransform.py b/pyqtgraph/SRTTransform.py
index efb24f60..23281343 100644
--- a/pyqtgraph/SRTTransform.py
+++ b/pyqtgraph/SRTTransform.py
@@ -2,7 +2,6 @@
 from .Qt import QtCore, QtGui
 from .Point import Point
 import numpy as np
-import pyqtgraph as pg
 
 class SRTTransform(QtGui.QTransform):
     """Transform that can always be represented as a combination of 3 matrices: scale * rotate * translate
@@ -77,7 +76,7 @@ class SRTTransform(QtGui.QTransform):
         self.update()
         
     def setFromMatrix4x4(self, m):
-        m = pg.SRTTransform3D(m)
+        m = SRTTransform3D(m)
         angle, axis = m.getRotation()
         if angle != 0 and (axis[0] != 0 or axis[1] != 0 or axis[2] != 1):
             print("angle: %s  axis: %s" % (str(angle), str(axis)))
@@ -256,4 +255,4 @@ if __name__ == '__main__':
     w1.sigRegionChanged.connect(update)
     #w2.sigRegionChanged.connect(update2)
     
-    
\ No newline at end of file
+from .SRTTransform3D import SRTTransform3D
diff --git a/pyqtgraph/SRTTransform3D.py b/pyqtgraph/SRTTransform3D.py
index 7d87dcb8..417190e1 100644
--- a/pyqtgraph/SRTTransform3D.py
+++ b/pyqtgraph/SRTTransform3D.py
@@ -1,17 +1,17 @@
 # -*- coding: utf-8 -*-
 from .Qt import QtCore, QtGui
 from .Vector import Vector
-from .SRTTransform import SRTTransform
-import pyqtgraph as pg
+from .Transform3D import Transform3D
+from .Vector import Vector
 import numpy as np
 import scipy.linalg
 
-class SRTTransform3D(pg.Transform3D):
+class SRTTransform3D(Transform3D):
     """4x4 Transform matrix that can always be represented as a combination of 3 matrices: scale * rotate * translate
     This transform has no shear; angles are always preserved.
     """
     def __init__(self, init=None):
-        pg.Transform3D.__init__(self)
+        Transform3D.__init__(self)
         self.reset()
         if init is None:
             return
@@ -44,14 +44,14 @@ class SRTTransform3D(pg.Transform3D):
 
         
     def getScale(self):
-        return pg.Vector(self._state['scale'])
+        return Vector(self._state['scale'])
         
     def getRotation(self):
         """Return (angle, axis) of rotation"""
-        return self._state['angle'], pg.Vector(self._state['axis'])
+        return self._state['angle'], Vector(self._state['axis'])
         
     def getTranslation(self):
-        return pg.Vector(self._state['pos'])
+        return Vector(self._state['pos'])
     
     def reset(self):
         self._state = {
@@ -169,7 +169,7 @@ class SRTTransform3D(pg.Transform3D):
         
     def as2D(self):
         """Return a QTransform representing the x,y portion of this transform (if possible)"""
-        return pg.SRTTransform(self)
+        return SRTTransform(self)
 
     #def __div__(self, t):
         #"""A / B  ==  B^-1 * A"""
@@ -202,11 +202,11 @@ class SRTTransform3D(pg.Transform3D):
         self.update()
 
     def update(self):
-        pg.Transform3D.setToIdentity(self)
+        Transform3D.setToIdentity(self)
         ## modifications to the transform are multiplied on the right, so we need to reverse order here.
-        pg.Transform3D.translate(self, *self._state['pos'])
-        pg.Transform3D.rotate(self, self._state['angle'], *self._state['axis'])
-        pg.Transform3D.scale(self, *self._state['scale'])
+        Transform3D.translate(self, *self._state['pos'])
+        Transform3D.rotate(self, self._state['angle'], *self._state['axis'])
+        Transform3D.scale(self, *self._state['scale'])
 
     def __repr__(self):
         return str(self.saveState())
@@ -311,4 +311,4 @@ if __name__ == '__main__':
     w1.sigRegionChanged.connect(update)
     #w2.sigRegionChanged.connect(update2)
     
-    	
\ No newline at end of file
+from .SRTTransform import SRTTransform
diff --git a/pyqtgraph/ThreadsafeTimer.py b/pyqtgraph/ThreadsafeTimer.py
index f2de9791..201469de 100644
--- a/pyqtgraph/ThreadsafeTimer.py
+++ b/pyqtgraph/ThreadsafeTimer.py
@@ -1,4 +1,4 @@
-from pyqtgraph.Qt import QtCore, QtGui
+from .Qt import QtCore, QtGui
 
 class ThreadsafeTimer(QtCore.QObject):
     """
diff --git a/pyqtgraph/Transform3D.py b/pyqtgraph/Transform3D.py
index aa948e28..43b12de3 100644
--- a/pyqtgraph/Transform3D.py
+++ b/pyqtgraph/Transform3D.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 from .Qt import QtCore, QtGui
-import pyqtgraph as pg
+from . import functions as fn
 import numpy as np
 
 class Transform3D(QtGui.QMatrix4x4):
@@ -26,7 +26,7 @@ class Transform3D(QtGui.QMatrix4x4):
         Extends QMatrix4x4.map() to allow mapping (3, ...) arrays of coordinates
         """
         if isinstance(obj, np.ndarray) and obj.ndim >= 2 and obj.shape[0] in (2,3):
-            return pg.transformCoordinates(self, obj)
+            return fn.transformCoordinates(self, obj)
         else:
             return QtGui.QMatrix4x4.map(self, obj)
             
diff --git a/pyqtgraph/colormap.py b/pyqtgraph/colormap.py
index d6169209..cb1e882e 100644
--- a/pyqtgraph/colormap.py
+++ b/pyqtgraph/colormap.py
@@ -1,6 +1,6 @@
 import numpy as np
 import scipy.interpolate
-from pyqtgraph.Qt import QtGui, QtCore
+from .Qt import QtGui, QtCore
 
 class ColorMap(object):
     """
diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py
index 80e61404..12588cf1 100644
--- a/pyqtgraph/functions.py
+++ b/pyqtgraph/functions.py
@@ -24,7 +24,7 @@ SI_PREFIXES_ASCII = 'yzafpnum kMGTPEZY'
 
 
 from .Qt import QtGui, QtCore, USE_PYSIDE
-import pyqtgraph as pg
+from . import getConfigOption, setConfigOptions
 import numpy as np
 import decimal, re
 import ctypes
@@ -33,11 +33,11 @@ import sys, struct
 try:
     import scipy.ndimage
     HAVE_SCIPY = True
-    if pg.getConfigOption('useWeave'):
+    if getConfigOption('useWeave'):
         try:
             import scipy.weave
         except ImportError:
-            pg.setConfigOptions(useWeave=False)
+            setConfigOptions(useWeave=False)
 except ImportError:
     HAVE_SCIPY = False
 
@@ -620,7 +620,7 @@ def rescaleData(data, scale, offset, dtype=None):
         dtype = np.dtype(dtype)
     
     try:
-        if not pg.getConfigOption('useWeave'):
+        if not getConfigOption('useWeave'):
             raise Exception('Weave is disabled; falling back to slower version.')
         
         ## require native dtype when using weave
@@ -647,10 +647,10 @@ def rescaleData(data, scale, offset, dtype=None):
             newData = newData.astype(dtype)
         data = newData.reshape(data.shape)
     except:
-        if pg.getConfigOption('useWeave'):
-            if pg.getConfigOption('weaveDebug'):
+        if getConfigOption('useWeave'):
+            if getConfigOption('weaveDebug'):
                 debug.printExc("Error; disabling weave.")
-            pg.setConfigOption('useWeave', False)
+            setConfigOptions(useWeave=False)
         
         #p = np.poly1d([scale, -offset*scale])
         #data = p(data).astype(dtype)
diff --git a/pyqtgraph/graphicsItems/ArrowItem.py b/pyqtgraph/graphicsItems/ArrowItem.py
index dcede02a..b15fc664 100644
--- a/pyqtgraph/graphicsItems/ArrowItem.py
+++ b/pyqtgraph/graphicsItems/ArrowItem.py
@@ -1,5 +1,5 @@
-from pyqtgraph.Qt import QtGui, QtCore
-import pyqtgraph.functions as fn
+from ..Qt import QtGui, QtCore
+from .. import functions as fn
 import numpy as np
 __all__ = ['ArrowItem']
 
diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py
index 3dd98cef..1d0b36b6 100644
--- a/pyqtgraph/graphicsItems/AxisItem.py
+++ b/pyqtgraph/graphicsItems/AxisItem.py
@@ -1,11 +1,11 @@
-from pyqtgraph.Qt import QtGui, QtCore
-from pyqtgraph.python2_3 import asUnicode
+from ..Qt import QtGui, QtCore
+from ..python2_3 import asUnicode
 import numpy as np
-from pyqtgraph.Point import Point
-import pyqtgraph.debug as debug
+from ..Point import Point
+from .. import debug as debug
 import weakref
-import pyqtgraph.functions as fn
-import pyqtgraph as pg
+from .. import functions as fn
+from .. import getConfigOption
 from .GraphicsWidget import GraphicsWidget
 
 __all__ = ['AxisItem']
@@ -268,8 +268,8 @@ class AxisItem(GraphicsWidget):
         
     def pen(self):
         if self._pen is None:
-            return fn.mkPen(pg.getConfigOption('foreground'))
-        return pg.mkPen(self._pen)
+            return fn.mkPen(getConfigOption('foreground'))
+        return fn.mkPen(self._pen)
         
     def setPen(self, pen):
         """
@@ -280,8 +280,8 @@ class AxisItem(GraphicsWidget):
         self._pen = pen
         self.picture = None
         if pen is None:
-            pen = pg.getConfigOption('foreground')
-        self.labelStyle['color'] = '#' + pg.colorStr(pg.mkPen(pen).color())[:6]
+            pen = getConfigOption('foreground')
+        self.labelStyle['color'] = '#' + fn.colorStr(fn.mkPen(pen).color())[:6]
         self.setLabel()
         self.update()
         
diff --git a/pyqtgraph/graphicsItems/BarGraphItem.py b/pyqtgraph/graphicsItems/BarGraphItem.py
index 0527e9f1..9f9dbcde 100644
--- a/pyqtgraph/graphicsItems/BarGraphItem.py
+++ b/pyqtgraph/graphicsItems/BarGraphItem.py
@@ -1,8 +1,10 @@
-import pyqtgraph as pg
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from .GraphicsObject import GraphicsObject
+from .. import getConfigOption
+from .. import functions as fn
 import numpy as np
 
+
 __all__ = ['BarGraphItem']
 
 class BarGraphItem(GraphicsObject):
@@ -61,7 +63,7 @@ class BarGraphItem(GraphicsObject):
         pens = self.opts['pens']
         
         if pen is None and pens is None:
-            pen = pg.getConfigOption('foreground')
+            pen = getConfigOption('foreground')
         
         brush = self.opts['brush']
         brushes = self.opts['brushes']
@@ -112,13 +114,13 @@ class BarGraphItem(GraphicsObject):
                 raise Exception('must specify either y1 or height')
             height = y1 - y0
         
-        p.setPen(pg.mkPen(pen))
-        p.setBrush(pg.mkBrush(brush))
+        p.setPen(fn.mkPen(pen))
+        p.setBrush(fn.mkBrush(brush))
         for i in range(len(x0)):
             if pens is not None:
-                p.setPen(pg.mkPen(pens[i]))
+                p.setPen(fn.mkPen(pens[i]))
             if brushes is not None:
-                p.setBrush(pg.mkBrush(brushes[i]))
+                p.setBrush(fn.mkBrush(brushes[i]))
                 
             if np.isscalar(y0):
                 y = y0
diff --git a/pyqtgraph/graphicsItems/ButtonItem.py b/pyqtgraph/graphicsItems/ButtonItem.py
index 741f2666..1c796823 100644
--- a/pyqtgraph/graphicsItems/ButtonItem.py
+++ b/pyqtgraph/graphicsItems/ButtonItem.py
@@ -1,4 +1,4 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from .GraphicsObject import GraphicsObject
 
 __all__ = ['ButtonItem']
diff --git a/pyqtgraph/graphicsItems/CurvePoint.py b/pyqtgraph/graphicsItems/CurvePoint.py
index 668830f7..f981bdf8 100644
--- a/pyqtgraph/graphicsItems/CurvePoint.py
+++ b/pyqtgraph/graphicsItems/CurvePoint.py
@@ -1,7 +1,7 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from . import ArrowItem
 import numpy as np
-from pyqtgraph.Point import Point
+from ..Point import Point
 import weakref
 from .GraphicsObject import GraphicsObject
 
diff --git a/pyqtgraph/graphicsItems/ErrorBarItem.py b/pyqtgraph/graphicsItems/ErrorBarItem.py
index 656b9e2e..7b681389 100644
--- a/pyqtgraph/graphicsItems/ErrorBarItem.py
+++ b/pyqtgraph/graphicsItems/ErrorBarItem.py
@@ -1,6 +1,7 @@
-import pyqtgraph as pg
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from .GraphicsObject import GraphicsObject
+from .. import getConfigOption
+from .. import functions as fn
 
 __all__ = ['ErrorBarItem']
 
@@ -121,8 +122,8 @@ class ErrorBarItem(GraphicsObject):
             self.drawPath()
         pen = self.opts['pen']
         if pen is None:
-            pen = pg.getConfigOption('foreground')
-        p.setPen(pg.mkPen(pen))
+            pen = getConfigOption('foreground')
+        p.setPen(fn.mkPen(pen))
         p.drawPath(self.path)
             
     def boundingRect(self):
diff --git a/pyqtgraph/graphicsItems/FillBetweenItem.py b/pyqtgraph/graphicsItems/FillBetweenItem.py
index e0011177..13e5fa6b 100644
--- a/pyqtgraph/graphicsItems/FillBetweenItem.py
+++ b/pyqtgraph/graphicsItems/FillBetweenItem.py
@@ -1,23 +1,24 @@
-import pyqtgraph as pg
+from ..Qt import QtGui
+from .. import functions as fn
 
-class FillBetweenItem(pg.QtGui.QGraphicsPathItem):
+class FillBetweenItem(QtGui.QGraphicsPathItem):
     """
     GraphicsItem filling the space between two PlotDataItems.
     """
     def __init__(self, p1, p2, brush=None):
-        pg.QtGui.QGraphicsPathItem.__init__(self)
+        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.setBrush(fn.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 = QtGui.QPainterPath()
         path.addPolygon(p1.toSubpathPolygons()[0] + p2.toReversed().toSubpathPolygons()[0])
         self.setPath(path)
diff --git a/pyqtgraph/graphicsItems/GradientEditorItem.py b/pyqtgraph/graphicsItems/GradientEditorItem.py
index 955106d8..f5158a74 100644
--- a/pyqtgraph/graphicsItems/GradientEditorItem.py
+++ b/pyqtgraph/graphicsItems/GradientEditorItem.py
@@ -1,11 +1,11 @@
-from pyqtgraph.Qt import QtGui, QtCore
-from pyqtgraph.python2_3 import sortList
-import pyqtgraph.functions as fn
+from ..Qt import QtGui, QtCore
+from ..python2_3 import sortList
+from .. import functions as fn
 from .GraphicsObject import GraphicsObject
 from .GraphicsWidget import GraphicsWidget
 import weakref
-from pyqtgraph.pgcollections import OrderedDict
-from pyqtgraph.colormap import ColorMap
+from ..pgcollections import OrderedDict
+from ..colormap import ColorMap
 
 import numpy as np
 
diff --git a/pyqtgraph/graphicsItems/GradientLegend.py b/pyqtgraph/graphicsItems/GradientLegend.py
index 4528b7ed..28c2cd63 100644
--- a/pyqtgraph/graphicsItems/GradientLegend.py
+++ b/pyqtgraph/graphicsItems/GradientLegend.py
@@ -1,6 +1,6 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from .UIGraphicsItem import *
-import pyqtgraph.functions as fn
+from .. import functions as fn
 
 __all__ = ['GradientLegend']
 
diff --git a/pyqtgraph/graphicsItems/GraphItem.py b/pyqtgraph/graphicsItems/GraphItem.py
index b1f34baa..63b5afbd 100644
--- a/pyqtgraph/graphicsItems/GraphItem.py
+++ b/pyqtgraph/graphicsItems/GraphItem.py
@@ -1,7 +1,7 @@
 from .. import functions as fn
 from .GraphicsObject import GraphicsObject
 from .ScatterPlotItem import ScatterPlotItem
-import pyqtgraph as pg
+from ..Qt import QtGui, QtCore
 import numpy as np
 
 __all__ = ['GraphItem']
@@ -71,11 +71,11 @@ class GraphItem(GraphicsObject):
         self.picture = None
 
     def generatePicture(self):
-        self.picture = pg.QtGui.QPicture()
+        self.picture = QtGui.QPicture()
         if self.pen is None or self.pos is None or self.adjacency is None:
             return
         
-        p = pg.QtGui.QPainter(self.picture)
+        p = QtGui.QPainter(self.picture)
         try:
             pts = self.pos[self.adjacency]
             pen = self.pen
@@ -86,14 +86,14 @@ class GraphItem(GraphicsObject):
                     if np.any(pen != lastPen):
                         lastPen = pen
                         if pen.dtype.fields is None:
-                            p.setPen(pg.mkPen(color=(pen[0], pen[1], pen[2], pen[3]), width=1))                            
+                            p.setPen(fn.mkPen(color=(pen[0], pen[1], pen[2], pen[3]), width=1))                            
                         else:
-                            p.setPen(pg.mkPen(color=(pen['red'], pen['green'], pen['blue'], pen['alpha']), width=pen['width']))
-                    p.drawLine(pg.QtCore.QPointF(*pts[i][0]), pg.QtCore.QPointF(*pts[i][1]))
+                            p.setPen(fn.mkPen(color=(pen['red'], pen['green'], pen['blue'], pen['alpha']), width=pen['width']))
+                    p.drawLine(QtCore.QPointF(*pts[i][0]), QtCore.QPointF(*pts[i][1]))
             else:
                 if pen == 'default':
-                    pen = pg.getConfigOption('foreground')
-                p.setPen(pg.mkPen(pen))
+                    pen = getConfigOption('foreground')
+                p.setPen(fn.mkPen(pen))
                 pts = pts.reshape((pts.shape[0]*pts.shape[1], pts.shape[2]))
                 path = fn.arrayToQPath(x=pts[:,0], y=pts[:,1], connect='pairs')
                 p.drawPath(path)
@@ -103,7 +103,7 @@ class GraphItem(GraphicsObject):
     def paint(self, p, *args):
         if self.picture == None:
             self.generatePicture()
-        if pg.getConfigOption('antialias') is True:
+        if getConfigOption('antialias') is True:
             p.setRenderHint(p.Antialiasing)
         self.picture.play(p)
         
diff --git a/pyqtgraph/graphicsItems/GraphicsItem.py b/pyqtgraph/graphicsItems/GraphicsItem.py
index 19cddd8a..8d2238b8 100644
--- a/pyqtgraph/graphicsItems/GraphicsItem.py
+++ b/pyqtgraph/graphicsItems/GraphicsItem.py
@@ -1,9 +1,9 @@
-from pyqtgraph.Qt import QtGui, QtCore  
-from pyqtgraph.GraphicsScene import GraphicsScene
-from pyqtgraph.Point import Point
-import pyqtgraph.functions as fn
+from ..Qt import QtGui, QtCore  
+from ..GraphicsScene import GraphicsScene
+from ..Point import Point
+from .. import functions as fn
 import weakref
-from pyqtgraph.pgcollections import OrderedDict
+from ..pgcollections import OrderedDict
 import operator, sys
 
 class FiniteCache(OrderedDict):
diff --git a/pyqtgraph/graphicsItems/GraphicsLayout.py b/pyqtgraph/graphicsItems/GraphicsLayout.py
index 9d48e627..a4016522 100644
--- a/pyqtgraph/graphicsItems/GraphicsLayout.py
+++ b/pyqtgraph/graphicsItems/GraphicsLayout.py
@@ -1,5 +1,5 @@
-from pyqtgraph.Qt import QtGui, QtCore
-import pyqtgraph.functions as fn
+from ..Qt import QtGui, QtCore
+from .. import functions as fn
 from .GraphicsWidget import GraphicsWidget
 ## Must be imported at the end to avoid cyclic-dependency hell:
 from .ViewBox import ViewBox
diff --git a/pyqtgraph/graphicsItems/GraphicsObject.py b/pyqtgraph/graphicsItems/GraphicsObject.py
index d8f55d27..1ea9a08b 100644
--- a/pyqtgraph/graphicsItems/GraphicsObject.py
+++ b/pyqtgraph/graphicsItems/GraphicsObject.py
@@ -1,4 +1,4 @@
-from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE
+from ..Qt import QtGui, QtCore, USE_PYSIDE
 if not USE_PYSIDE:
     import sip
 from .GraphicsItem import GraphicsItem
diff --git a/pyqtgraph/graphicsItems/GraphicsWidget.py b/pyqtgraph/graphicsItems/GraphicsWidget.py
index 7650b125..c379ce8e 100644
--- a/pyqtgraph/graphicsItems/GraphicsWidget.py
+++ b/pyqtgraph/graphicsItems/GraphicsWidget.py
@@ -1,5 +1,5 @@
-from pyqtgraph.Qt import QtGui, QtCore  
-from pyqtgraph.GraphicsScene import GraphicsScene
+from ..Qt import QtGui, QtCore  
+from ..GraphicsScene import GraphicsScene
 from .GraphicsItem import GraphicsItem
 
 __all__ = ['GraphicsWidget']
diff --git a/pyqtgraph/graphicsItems/GridItem.py b/pyqtgraph/graphicsItems/GridItem.py
index 29b0aa2c..87f90a62 100644
--- a/pyqtgraph/graphicsItems/GridItem.py
+++ b/pyqtgraph/graphicsItems/GridItem.py
@@ -1,8 +1,8 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from .UIGraphicsItem import *
 import numpy as np
-from pyqtgraph.Point import Point
-import pyqtgraph.functions as fn
+from ..Point import Point
+from .. import functions as fn
 
 __all__ = ['GridItem']
 class GridItem(UIGraphicsItem):
diff --git a/pyqtgraph/graphicsItems/HistogramLUTItem.py b/pyqtgraph/graphicsItems/HistogramLUTItem.py
index 70d8662f..8474202c 100644
--- a/pyqtgraph/graphicsItems/HistogramLUTItem.py
+++ b/pyqtgraph/graphicsItems/HistogramLUTItem.py
@@ -3,8 +3,8 @@ GraphicsWidget displaying an image histogram along with gradient editor. Can be
 """
 
 
-from pyqtgraph.Qt import QtGui, QtCore
-import pyqtgraph.functions as fn
+from ..Qt import QtGui, QtCore
+from .. import functions as fn
 from .GraphicsWidget import GraphicsWidget
 from .ViewBox import *
 from .GradientEditorItem import *
@@ -12,10 +12,10 @@ from .LinearRegionItem import *
 from .PlotDataItem import *
 from .AxisItem import *
 from .GridItem import *
-from pyqtgraph.Point import Point
-import pyqtgraph.functions as fn
+from ..Point import Point
+from .. import functions as fn
 import numpy as np
-import pyqtgraph.debug as debug
+from .. import debug as debug
 
 
 __all__ = ['HistogramLUTItem']
diff --git a/pyqtgraph/graphicsItems/ImageItem.py b/pyqtgraph/graphicsItems/ImageItem.py
index f7a211d9..120312ad 100644
--- a/pyqtgraph/graphicsItems/ImageItem.py
+++ b/pyqtgraph/graphicsItems/ImageItem.py
@@ -1,8 +1,8 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 import numpy as np
 import collections
-import pyqtgraph.functions as fn
-import pyqtgraph.debug as debug
+from .. import functions as fn
+from .. import debug as debug
 from .GraphicsObject import GraphicsObject
 
 __all__ = ['ImageItem']
diff --git a/pyqtgraph/graphicsItems/InfiniteLine.py b/pyqtgraph/graphicsItems/InfiniteLine.py
index 4f0df863..edf6b19e 100644
--- a/pyqtgraph/graphicsItems/InfiniteLine.py
+++ b/pyqtgraph/graphicsItems/InfiniteLine.py
@@ -1,7 +1,7 @@
-from pyqtgraph.Qt import QtGui, QtCore
-from pyqtgraph.Point import Point
+from ..Qt import QtGui, QtCore
+from ..Point import Point
 from .GraphicsObject import GraphicsObject
-import pyqtgraph.functions as fn
+from .. import functions as fn
 import numpy as np
 import weakref
 
diff --git a/pyqtgraph/graphicsItems/IsocurveItem.py b/pyqtgraph/graphicsItems/IsocurveItem.py
index 01ef57b6..71113ba8 100644
--- a/pyqtgraph/graphicsItems/IsocurveItem.py
+++ b/pyqtgraph/graphicsItems/IsocurveItem.py
@@ -1,8 +1,8 @@
 
 
 from .GraphicsObject import *
-import pyqtgraph.functions as fn
-from pyqtgraph.Qt import QtGui, QtCore
+from .. import functions as fn
+from ..Qt import QtGui, QtCore
 
 
 class IsocurveItem(GraphicsObject):
diff --git a/pyqtgraph/graphicsItems/ItemGroup.py b/pyqtgraph/graphicsItems/ItemGroup.py
index 930fdf80..4eb0ee0d 100644
--- a/pyqtgraph/graphicsItems/ItemGroup.py
+++ b/pyqtgraph/graphicsItems/ItemGroup.py
@@ -1,4 +1,4 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from .GraphicsObject import GraphicsObject
 
 __all__ = ['ItemGroup']
diff --git a/pyqtgraph/graphicsItems/LabelItem.py b/pyqtgraph/graphicsItems/LabelItem.py
index 6101c4bc..37980ee3 100644
--- a/pyqtgraph/graphicsItems/LabelItem.py
+++ b/pyqtgraph/graphicsItems/LabelItem.py
@@ -1,8 +1,8 @@
-from pyqtgraph.Qt import QtGui, QtCore
-import pyqtgraph.functions as fn
-import pyqtgraph as pg
+from ..Qt import QtGui, QtCore
+from .. import functions as fn
 from .GraphicsWidget import GraphicsWidget
 from .GraphicsWidgetAnchor import GraphicsWidgetAnchor
+from .. import getConfigOption
 
 
 __all__ = ['LabelItem']
@@ -54,7 +54,7 @@ class LabelItem(GraphicsWidget, GraphicsWidgetAnchor):
         
         color = self.opts['color']
         if color is None:
-            color = pg.getConfigOption('foreground')
+            color = getConfigOption('foreground')
         color = fn.mkColor(color)
         optlist.append('color: #' + fn.colorStr(color)[:6])
         if 'size' in opts:
diff --git a/pyqtgraph/graphicsItems/LegendItem.py b/pyqtgraph/graphicsItems/LegendItem.py
index 69ddffea..a1228789 100644
--- a/pyqtgraph/graphicsItems/LegendItem.py
+++ b/pyqtgraph/graphicsItems/LegendItem.py
@@ -3,8 +3,9 @@ from .LabelItem import LabelItem
 from ..Qt import QtGui, QtCore
 from .. import functions as fn
 from ..Point import Point
+from .ScatterPlotItem import ScatterPlotItem
+from .PlotDataItem import PlotDataItem
 from .GraphicsWidgetAnchor import GraphicsWidgetAnchor
-import pyqtgraph as pg
 __all__ = ['LegendItem']
 
 class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
@@ -152,21 +153,21 @@ class ItemSample(GraphicsWidget):
             p.setPen(fn.mkPen(None))
             p.drawPolygon(QtGui.QPolygonF([QtCore.QPointF(2,18), QtCore.QPointF(18,2), QtCore.QPointF(18,18)]))
         
-        if not isinstance(self.item, pg.ScatterPlotItem):
+        if not isinstance(self.item, ScatterPlotItem):
             p.setPen(fn.mkPen(opts['pen']))
             p.drawLine(2, 18, 18, 2)
         
         symbol = opts.get('symbol', None)
         if symbol is not None:
-            if isinstance(self.item, pg.PlotDataItem):
+            if isinstance(self.item, PlotDataItem):
                 opts = self.item.scatter.opts
                 
-            pen = pg.mkPen(opts['pen'])
-            brush = pg.mkBrush(opts['brush'])
+            pen = fn.mkPen(opts['pen'])
+            brush = fn.mkBrush(opts['brush'])
             size = opts['size']
             
             p.translate(10,10)
-            path = pg.graphicsItems.ScatterPlotItem.drawSymbol(p, symbol, size, pen, brush)
+            path = ScatterPlotItem.drawSymbol(p, symbol, size, pen, brush)
         
         
         
diff --git a/pyqtgraph/graphicsItems/LinearRegionItem.py b/pyqtgraph/graphicsItems/LinearRegionItem.py
index 08f7e198..4f9d28dc 100644
--- a/pyqtgraph/graphicsItems/LinearRegionItem.py
+++ b/pyqtgraph/graphicsItems/LinearRegionItem.py
@@ -1,8 +1,8 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from .UIGraphicsItem import UIGraphicsItem
 from .InfiniteLine import InfiniteLine
-import pyqtgraph.functions as fn
-import pyqtgraph.debug as debug
+from .. import functions as fn
+from .. import debug as debug
 
 __all__ = ['LinearRegionItem']
 
diff --git a/pyqtgraph/graphicsItems/PlotCurveItem.py b/pyqtgraph/graphicsItems/PlotCurveItem.py
index 93ef195b..b2beaa99 100644
--- a/pyqtgraph/graphicsItems/PlotCurveItem.py
+++ b/pyqtgraph/graphicsItems/PlotCurveItem.py
@@ -1,17 +1,17 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 try:
-    from pyqtgraph.Qt import QtOpenGL
+    from ..Qt import QtOpenGL
     HAVE_OPENGL = True
 except:
     HAVE_OPENGL = False
     
 import numpy as np
 from .GraphicsObject import GraphicsObject
-import pyqtgraph.functions as fn
-from pyqtgraph import debug
-from pyqtgraph.Point import Point
-import pyqtgraph as pg
+from .. import functions as fn
+from ..Point import Point
 import struct, sys
+from .. import getConfigOption
+from .. import debug
 
 __all__ = ['PlotCurveItem']
 class PlotCurveItem(GraphicsObject):
@@ -65,7 +65,7 @@ class PlotCurveItem(GraphicsObject):
             'brush': None,
             'stepMode': False,
             'name': None,
-            'antialias': pg.getConfigOption('antialias'),
+            'antialias': getConfigOption('antialias'),
             'connect': 'all',
             'mouseWidth': 8, # width of shape responding to mouse click
         }
@@ -399,13 +399,13 @@ class PlotCurveItem(GraphicsObject):
             self._mouseShape = None
         return self.path
 
-    @pg.debug.warnOnException  ## raising an exception here causes crash
+    @debug.warnOnException  ## raising an exception here causes crash
     def paint(self, p, opt, widget):
         profiler = debug.Profiler()
         if self.xData is None:
             return
         
-        if HAVE_OPENGL and pg.getConfigOption('enableExperimental') and isinstance(widget, QtOpenGL.QGLWidget):
+        if HAVE_OPENGL and getConfigOption('enableExperimental') and isinstance(widget, QtOpenGL.QGLWidget):
             self.paintGL(p, opt, widget)
             return
         
diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py
index 7d46d65c..e8c4145c 100644
--- a/pyqtgraph/graphicsItems/PlotDataItem.py
+++ b/pyqtgraph/graphicsItems/PlotDataItem.py
@@ -1,12 +1,12 @@
-import pyqtgraph.metaarray as metaarray
-from pyqtgraph.Qt import QtCore
+from .. import metaarray as metaarray
+from ..Qt import QtCore
 from .GraphicsObject import GraphicsObject
 from .PlotCurveItem import PlotCurveItem
 from .ScatterPlotItem import ScatterPlotItem
 import numpy as np
-import pyqtgraph.functions as fn
-import pyqtgraph.debug as debug
-import pyqtgraph as pg
+from .. import functions as fn
+from .. import debug as debug
+from .. import getConfigOption
 
 class PlotDataItem(GraphicsObject):
     """
@@ -152,7 +152,7 @@ class PlotDataItem(GraphicsObject):
             'symbolBrush': (50, 50, 150),
             'pxMode': True,
             
-            'antialias': pg.getConfigOption('antialias'),
+            'antialias': getConfigOption('antialias'),
             'pointMode': None,
             
             'downsample': 1,
diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py
index cb5f4f30..0dee2fd4 100644
--- a/pyqtgraph/graphicsItems/ROI.py
+++ b/pyqtgraph/graphicsItems/ROI.py
@@ -12,16 +12,16 @@ The ROI class is meant to serve as the base for more specific types; see several
 of how to build an ROI at the bottom of the file.
 """
 
-from pyqtgraph.Qt import QtCore, QtGui
+from ..Qt import QtCore, QtGui
 #if not hasattr(QtCore, 'Signal'):
     #QtCore.Signal = QtCore.pyqtSignal
 import numpy as np
 from numpy.linalg import norm
 import scipy.ndimage as ndimage
-from pyqtgraph.Point import *
-from pyqtgraph.SRTTransform import SRTTransform
+from ..Point import *
+from ..SRTTransform import SRTTransform
 from math import cos, sin
-import pyqtgraph.functions as fn
+from .. import functions as fn
 from .GraphicsObject import GraphicsObject
 from .UIGraphicsItem import UIGraphicsItem
 
diff --git a/pyqtgraph/graphicsItems/ScaleBar.py b/pyqtgraph/graphicsItems/ScaleBar.py
index 768f6978..66258678 100644
--- a/pyqtgraph/graphicsItems/ScaleBar.py
+++ b/pyqtgraph/graphicsItems/ScaleBar.py
@@ -1,10 +1,10 @@
-from pyqtgraph.Qt import QtGui, QtCore
+from ..Qt import QtGui, QtCore
 from .GraphicsObject import *
 from .GraphicsWidgetAnchor import *
 from .TextItem import TextItem
 import numpy as np
-import pyqtgraph.functions as fn
-import pyqtgraph as pg
+from .. import functions as fn
+from .. import getConfigOption
 
 __all__ = ['ScaleBar']
 
@@ -19,7 +19,7 @@ class ScaleBar(GraphicsObject, GraphicsWidgetAnchor):
         self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
         
         if brush is None:
-            brush = pg.getConfigOption('foreground')
+            brush = getConfigOption('foreground')
         self.brush = fn.mkBrush(brush)
         self.pen = fn.mkPen(pen)
         self._width = width
diff --git a/pyqtgraph/graphicsItems/ScatterPlotItem.py b/pyqtgraph/graphicsItems/ScatterPlotItem.py
index 498df2cd..926c9045 100644
--- a/pyqtgraph/graphicsItems/ScatterPlotItem.py
+++ b/pyqtgraph/graphicsItems/ScatterPlotItem.py
@@ -1,14 +1,14 @@
-from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE
-from pyqtgraph.Point import Point
-import pyqtgraph.functions as fn
+from ..Qt import QtGui, QtCore, USE_PYSIDE
+from ..Point import Point
+from .. import functions as fn
 from .GraphicsItem import GraphicsItem
 from .GraphicsObject import GraphicsObject
 import numpy as np
 import weakref
-import pyqtgraph.debug as debug
-from pyqtgraph.pgcollections import OrderedDict
-import pyqtgraph as pg
-#import pyqtgraph as pg 
+from .. import getConfigOption
+from .. import debug as debug
+from ..pgcollections import OrderedDict
+from .. import debug
 
 __all__ = ['ScatterPlotItem', 'SpotItem']
 
@@ -233,7 +233,7 @@ class ScatterPlotItem(GraphicsObject):
         self.opts = {
             'pxMode': True, 
             'useCache': True,  ## If useCache is False, symbols are re-drawn on every paint. 
-            'antialias': pg.getConfigOption('antialias'),
+            'antialias': getConfigOption('antialias'),
             'name': None,
         }   
         
@@ -693,7 +693,7 @@ class ScatterPlotItem(GraphicsObject):
         GraphicsObject.setExportMode(self, *args, **kwds)
         self.invalidate()
         
-    @pg.debug.warnOnException  ## raising an exception here causes crash
+    @debug.warnOnException  ## raising an exception here causes crash
     def paint(self, p, *args):
 
         #p.setPen(fn.mkPen('r'))
diff --git a/pyqtgraph/graphicsItems/TextItem.py b/pyqtgraph/graphicsItems/TextItem.py
index 911057f4..2b5ea51c 100644
--- a/pyqtgraph/graphicsItems/TextItem.py
+++ b/pyqtgraph/graphicsItems/TextItem.py
@@ -1,7 +1,7 @@
-from pyqtgraph.Qt import QtCore, QtGui
-import pyqtgraph as pg
+from ..Qt import QtCore, QtGui
+from ..Point import Point
 from .UIGraphicsItem import *
-import pyqtgraph.functions as fn
+from .. import functions as fn
 
 class TextItem(UIGraphicsItem):
     """
@@ -27,7 +27,7 @@ class TextItem(UIGraphicsItem):
         #*angle*      Angle in degrees to rotate text (note that the rotation assigned in this item's 
                      #transformation will be ignored)
                      
-        self.anchor = pg.Point(anchor)
+        self.anchor = Point(anchor)
         #self.angle = 0
         UIGraphicsItem.__init__(self)
         self.textItem = QtGui.QGraphicsTextItem()
@@ -38,13 +38,13 @@ class TextItem(UIGraphicsItem):
             self.setText(text, color)
         else:
             self.setHtml(html)
-        self.fill = pg.mkBrush(fill)
-        self.border = pg.mkPen(border)
+        self.fill = fn.mkBrush(fill)
+        self.border = fn.mkPen(border)
         self.rotate(angle)
         self.setFlag(self.ItemIgnoresTransformations)  ## This is required to keep the text unscaled inside the viewport
 
     def setText(self, text, color=(200,200,200)):
-        color = pg.mkColor(color)
+        color = fn.mkColor(color)
         self.textItem.setDefaultTextColor(color)
         self.textItem.setPlainText(text)
         self.updateText()
@@ -89,7 +89,7 @@ class TextItem(UIGraphicsItem):
         #br = self.textItem.mapRectToParent(self.textItem.boundingRect())
         self.textItem.setPos(0,0)
         br = self.textItem.boundingRect()
-        apos = self.textItem.mapToParent(pg.Point(br.width()*self.anchor.x(), br.height()*self.anchor.y()))
+        apos = self.textItem.mapToParent(Point(br.width()*self.anchor.x(), br.height()*self.anchor.y()))
         #print br, apos
         self.textItem.setPos(-apos.x(), -apos.y())
         
diff --git a/pyqtgraph/graphicsItems/UIGraphicsItem.py b/pyqtgraph/graphicsItems/UIGraphicsItem.py
index 19fda424..6f756334 100644
--- a/pyqtgraph/graphicsItems/UIGraphicsItem.py
+++ b/pyqtgraph/graphicsItems/UIGraphicsItem.py
@@ -1,4 +1,4 @@
-from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE
+from ..Qt import QtGui, QtCore, USE_PYSIDE
 import weakref
 from .GraphicsObject import GraphicsObject
 if not USE_PYSIDE:
diff --git a/pyqtgraph/graphicsItems/VTickGroup.py b/pyqtgraph/graphicsItems/VTickGroup.py
index c6880f91..4b315678 100644
--- a/pyqtgraph/graphicsItems/VTickGroup.py
+++ b/pyqtgraph/graphicsItems/VTickGroup.py
@@ -3,8 +3,8 @@ if __name__ == '__main__':
     path = os.path.abspath(os.path.dirname(__file__))
     sys.path.insert(0, os.path.join(path, '..', '..'))
 
-from pyqtgraph.Qt import QtGui, QtCore
-import pyqtgraph.functions as fn
+from ..Qt import QtGui, QtCore
+from .. import functions as fn
 import weakref
 from .UIGraphicsItem import UIGraphicsItem
 
@@ -96,18 +96,4 @@ class VTickGroup(UIGraphicsItem):
         p.setPen(self.pen)
         p.drawPath(self.path)
 
-
-if __name__ == '__main__':
-    app = QtGui.QApplication([])
-    import pyqtgraph as pg
-    vt = VTickGroup([1,3,4,7,9], [0.8, 1.0])
-    p = pg.plot()
-    p.addItem(vt)
-    
-    if sys.flags.interactive == 0:
-        app.exec_()
-    
-    
-    
-    
     
\ No newline at end of file
-- 
GitLab