Commit dc597ac5 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

fixes for pyside compatibility

parent 9baa0116
## Do all Qt imports from here to allow easier PyQt / PySide compatibility
#from PySide import QtGui, QtCore, QtOpenGL, QtSvg
from PyQt4 import QtGui, QtCore, QtOpenGL, QtSvg
if not hasattr(QtCore, 'Signal'):
QtCore.Signal = QtCore.pyqtSignal
from PySide import QtGui, QtCore, QtOpenGL, QtSvg
#from PyQt4 import QtGui, QtCore, QtOpenGL, QtSvg
#if not hasattr(QtCore, 'Signal'):
# QtCore.Signal = QtCore.pyqtSignal
......@@ -4,7 +4,7 @@ import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
import numpy as np
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
......
......@@ -3,7 +3,7 @@ import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
......
......@@ -4,7 +4,7 @@ import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
import numpy as np
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
......
......@@ -2,7 +2,7 @@
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import user
......
......@@ -5,7 +5,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
import numpy as np
import scipy.ndimage as ndi
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
......
......@@ -7,7 +7,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from scipy import random
from numpy import linspace
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
from pyqtgraph import MultiPlotWidget
try:
......
......@@ -5,7 +5,7 @@ import sys, os, time
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
......
......@@ -5,7 +5,7 @@ import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
......
......@@ -5,7 +5,7 @@ import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
......
......@@ -3,7 +3,7 @@ import sys, os
## Add path to library (just for examples; you do not need this)
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import numpy as np
......
......@@ -5,7 +5,7 @@ import sys, os, time
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
from pyqtgraph import RawImageWidget
......
......@@ -8,7 +8,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
#from scipy import random
import numpy as np
from PyQt4 import QtGui, QtCore
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
app = QtGui.QApplication([])
......
from PyQt4 import QtCore, QtGui
import sys, os
## make sure this pyqtgraph is importable before any others
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
from pyqtgraph.Qt import QtCore, QtGui
from exampleLoaderTemplate import Ui_Form
import os, sys
from collections import OrderedDict
......@@ -98,4 +102,4 @@ def run():
app.exec_()
if __name__ == '__main__':
run()
\ No newline at end of file
run()
......@@ -51,7 +51,6 @@ class GraphicsItemMethods(object):
if hasattr(p, 'implements') and p.implements('ViewBox'):
self._viewBox = weakref.ref(p)
break
return self._viewBox() ## If we made it this far, _viewBox is definitely not None
def forgetViewBox(self):
......@@ -78,7 +77,10 @@ class GraphicsItemMethods(object):
if view is None:
return None
if hasattr(view, 'implements') and view.implements('ViewBox'):
return self.itemTransform(view.innerSceneItem())[0]
tr = self.itemTransform(view.innerSceneItem())
if isinstance(tr, tuple):
tr = tr[0] ## difference between pyside and pyqt
return tr
else:
return self.sceneTransform()
#return self.deviceTransform(view.viewportTransform())
......@@ -102,7 +104,11 @@ class GraphicsItemMethods(object):
view = self.getViewBox()
if view is None:
return None
bounds = self.mapRectFromView(view.viewRect()).normalized()
bounds = self.mapRectFromView(view.viewRect())
if bounds is None:
return None
bounds = bounds.normalized()
## nah.
#for p in self.getBoundingParents():
......@@ -246,7 +252,10 @@ class GraphicsItemMethods(object):
if relativeItem is None:
relativeItem = self.parentItem()
tr = self.itemTransform(relativeItem)[0]
tr = self.itemTransform(relativeItem)
if isinstance(tr, tuple): ## difference between pyside and pyqt
tr = tr[0]
vec = tr.map(Point(1,0)) - tr.map(Point(0,0))
return Point(vec).angle(Point(1,0))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment