minor code cleanup
bugfixes for pyside-specific issues
This commit is contained in:
parent
a90d00a536
commit
3f486d9a65
@ -13,10 +13,13 @@ from .mouseEvents import *
|
|||||||
import pyqtgraph.debug as debug
|
import pyqtgraph.debug as debug
|
||||||
from . import exportDialog
|
from . import exportDialog
|
||||||
|
|
||||||
try:
|
if hasattr(QtCore, 'PYQT_VERSION'):
|
||||||
import sip
|
try:
|
||||||
HAVE_SIP = True
|
import sip
|
||||||
except:
|
HAVE_SIP = True
|
||||||
|
except ImportError:
|
||||||
|
HAVE_SIP = False
|
||||||
|
else:
|
||||||
HAVE_SIP = False
|
HAVE_SIP = False
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,7 +193,10 @@ show = image ## for backward compatibility
|
|||||||
|
|
||||||
def mkQApp():
|
def mkQApp():
|
||||||
global QAPP
|
global QAPP
|
||||||
if QtGui.QApplication.instance() is None:
|
inst = QtGui.QApplication.instance()
|
||||||
|
if inst is None:
|
||||||
QAPP = QtGui.QApplication([])
|
QAPP = QtGui.QApplication([])
|
||||||
|
else:
|
||||||
|
QAPP = inst
|
||||||
return QAPP
|
return QAPP
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class GraphicsItem(object):
|
|||||||
if view is None:
|
if view is None:
|
||||||
return None
|
return None
|
||||||
viewportTransform = view.viewportTransform()
|
viewportTransform = view.viewportTransform()
|
||||||
dt = QtGui.QGraphicsObject.deviceTransform(self, viewportTransform)
|
dt = self._qtBaseClass.deviceTransform(self, viewportTransform)
|
||||||
|
|
||||||
#xmag = abs(dt.m11())+abs(dt.m12())
|
#xmag = abs(dt.m11())+abs(dt.m12())
|
||||||
#ymag = abs(dt.m21())+abs(dt.m22())
|
#ymag = abs(dt.m21())+abs(dt.m22())
|
||||||
@ -274,19 +274,26 @@ class GraphicsItem(object):
|
|||||||
return vt.mapRect(obj)
|
return vt.mapRect(obj)
|
||||||
|
|
||||||
def pos(self):
|
def pos(self):
|
||||||
return Point(QtGui.QGraphicsObject.pos(self))
|
return Point(self._qtBaseClass.pos(self))
|
||||||
|
|
||||||
def viewPos(self):
|
def viewPos(self):
|
||||||
return self.mapToView(self.mapFromParent(self.pos()))
|
return self.mapToView(self.mapFromParent(self.pos()))
|
||||||
|
|
||||||
def parentItem(self):
|
def parentItem(self):
|
||||||
## PyQt bug -- some items are returned incorrectly.
|
## PyQt bug -- some items are returned incorrectly.
|
||||||
return GraphicsScene.translateGraphicsItem(QtGui.QGraphicsObject.parentItem(self))
|
return GraphicsScene.translateGraphicsItem(self._qtBaseClass.parentItem(self))
|
||||||
|
|
||||||
|
def setParentItem(self, parent):
|
||||||
|
## Workaround for Qt bug: https://bugreports.qt-project.org/browse/QTBUG-18616
|
||||||
|
if parent is not None:
|
||||||
|
pscene = parent.scene()
|
||||||
|
if pscene is not None and self.scene() is not pscene:
|
||||||
|
pscene.addItem(self)
|
||||||
|
return self._qtBaseClass.setParentItem(self, parent)
|
||||||
|
|
||||||
def childItems(self):
|
def childItems(self):
|
||||||
## PyQt bug -- some child items are returned incorrectly.
|
## PyQt bug -- some child items are returned incorrectly.
|
||||||
return list(map(GraphicsScene.translateGraphicsItem, QtGui.QGraphicsObject.childItems(self)))
|
return list(map(GraphicsScene.translateGraphicsItem, self._qtBaseClass.childItems(self)))
|
||||||
|
|
||||||
|
|
||||||
def sceneTransform(self):
|
def sceneTransform(self):
|
||||||
@ -296,7 +303,7 @@ class GraphicsItem(object):
|
|||||||
if self.scene() is None:
|
if self.scene() is None:
|
||||||
return self.transform()
|
return self.transform()
|
||||||
else:
|
else:
|
||||||
return QtGui.QGraphicsObject.sceneTransform(self)
|
return self._qtBaseClass.sceneTransform(self)
|
||||||
|
|
||||||
|
|
||||||
def transformAngle(self, relativeItem=None):
|
def transformAngle(self, relativeItem=None):
|
||||||
@ -315,7 +322,7 @@ class GraphicsItem(object):
|
|||||||
|
|
||||||
|
|
||||||
#def itemChange(self, change, value):
|
#def itemChange(self, change, value):
|
||||||
#ret = QtGui.QGraphicsObject.itemChange(self, change, value)
|
#ret = self._qtBaseClass.itemChange(self, change, value)
|
||||||
#if change == self.ItemParentHasChanged or change == self.ItemSceneHasChanged:
|
#if change == self.ItemParentHasChanged or change == self.ItemSceneHasChanged:
|
||||||
#print "Item scene changed:", self
|
#print "Item scene changed:", self
|
||||||
#self.setChildScene(self) ## This is bizarre.
|
#self.setChildScene(self) ## This is bizarre.
|
||||||
|
@ -8,6 +8,7 @@ class GraphicsObject(GraphicsItem, QtGui.QGraphicsObject):
|
|||||||
|
|
||||||
Extension of QGraphicsObject with some useful methods (provided by :class:`GraphicsItem <pyqtgraph.graphicsItems.GraphicsItem>`)
|
Extension of QGraphicsObject with some useful methods (provided by :class:`GraphicsItem <pyqtgraph.graphicsItems.GraphicsItem>`)
|
||||||
"""
|
"""
|
||||||
|
_qtBaseClass = QtGui.QGraphicsObject
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
QtGui.QGraphicsObject.__init__(self, *args)
|
QtGui.QGraphicsObject.__init__(self, *args)
|
||||||
GraphicsItem.__init__(self)
|
GraphicsItem.__init__(self)
|
||||||
@ -17,13 +18,3 @@ class GraphicsObject(GraphicsItem, QtGui.QGraphicsObject):
|
|||||||
if change in [self.ItemParentHasChanged, self.ItemSceneHasChanged]:
|
if change in [self.ItemParentHasChanged, self.ItemSceneHasChanged]:
|
||||||
self._updateView()
|
self._updateView()
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def setParentItem(self, parent):
|
|
||||||
## Workaround for Qt bug: https://bugreports.qt-project.org/browse/QTBUG-18616
|
|
||||||
if parent is not None:
|
|
||||||
pscene = parent.scene()
|
|
||||||
if pscene is not None and self.scene() is not pscene:
|
|
||||||
pscene.addItem(self)
|
|
||||||
return QtGui.QGraphicsObject.setParentItem(self, parent)
|
|
||||||
|
@ -5,6 +5,8 @@ from .GraphicsItem import GraphicsItem
|
|||||||
__all__ = ['GraphicsWidget']
|
__all__ = ['GraphicsWidget']
|
||||||
|
|
||||||
class GraphicsWidget(GraphicsItem, QtGui.QGraphicsWidget):
|
class GraphicsWidget(GraphicsItem, QtGui.QGraphicsWidget):
|
||||||
|
|
||||||
|
_qtBaseClass = QtGui.QGraphicsWidget
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
"""
|
"""
|
||||||
**Bases:** :class:`GraphicsItem <pyqtgraph.GraphicsItem>`, :class:`QtGui.QGraphicsWidget`
|
**Bases:** :class:`GraphicsItem <pyqtgraph.GraphicsItem>`, :class:`QtGui.QGraphicsWidget`
|
||||||
@ -14,7 +16,9 @@ class GraphicsWidget(GraphicsItem, QtGui.QGraphicsWidget):
|
|||||||
"""
|
"""
|
||||||
QtGui.QGraphicsWidget.__init__(self, *args, **kargs)
|
QtGui.QGraphicsWidget.__init__(self, *args, **kargs)
|
||||||
GraphicsItem.__init__(self)
|
GraphicsItem.__init__(self)
|
||||||
GraphicsScene.registerObject(self) ## workaround for pyqt bug in graphicsscene.items()
|
|
||||||
|
## done by GraphicsItem init
|
||||||
|
#GraphicsScene.registerObject(self) ## workaround for pyqt bug in graphicsscene.items()
|
||||||
|
|
||||||
## Removed because this causes segmentation faults. Don't know why.
|
## Removed because this causes segmentation faults. Don't know why.
|
||||||
# def itemChange(self, change, value):
|
# def itemChange(self, change, value):
|
||||||
@ -52,11 +56,3 @@ class GraphicsWidget(GraphicsItem, QtGui.QGraphicsWidget):
|
|||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def setParentItem(self, parent):
|
|
||||||
## Workaround for Qt bug: https://bugreports.qt-project.org/browse/QTBUG-18616
|
|
||||||
if parent is not None:
|
|
||||||
pscene = parent.scene()
|
|
||||||
if pscene is not None and self.scene() is not pscene:
|
|
||||||
pscene.addItem(self)
|
|
||||||
return QtGui.QGraphicsObject.setParentItem(self, parent)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user