Source code for pyqtgraph.graphicsItems.GraphicsObject

from ..Qt import QtCore, QtWidgets, QT_LIB

from .GraphicsItem import GraphicsItem

__all__ = ['GraphicsObject']
[docs]class GraphicsObject(GraphicsItem, QtWidgets.QGraphicsObject): """ **Bases:** :class:`GraphicsItem <pyqtgraph.graphicsItems.GraphicsItem>`, :class:`QtWidgets.QGraphicsObject` Extension of QGraphicsObject with some useful methods (provided by :class:`GraphicsItem <pyqtgraph.graphicsItems.GraphicsItem>`) """ _qtBaseClass = QtWidgets.QGraphicsObject
[docs] def __init__(self, *args): self.__inform_view_on_changes = True QtWidgets.QGraphicsObject.__init__(self, *args) self.setFlag(self.GraphicsItemFlag.ItemSendsGeometryChanges) GraphicsItem.__init__(self)
def itemChange(self, change, value): ret = super().itemChange(change, value) if change in [self.GraphicsItemChange.ItemParentHasChanged, self.GraphicsItemChange.ItemSceneHasChanged]: if QT_LIB == 'PySide6' and QtCore.__version_info__ == (6, 2, 2): # workaround PySide6 6.2.2 issue https://bugreports.qt.io/browse/PYSIDE-1730 # note that the bug exists also in PySide6 6.2.2.1 / Qt 6.2.2 getattr(self.__class__, 'parentChanged')(self) else: self.parentChanged() try: inform_view_on_change = self.__inform_view_on_changes except AttributeError: # It's possible that the attribute was already collected when the itemChange happened # (if it was triggered during the gc of the object). pass else: if inform_view_on_change and change in [self.GraphicsItemChange.ItemPositionHasChanged, self.GraphicsItemChange.ItemTransformHasChanged]: self.informViewBoundsChanged() return ret