Skip to content

GraphicsItemMixin

Sub classes

Name Children Inherits
GraphicsItem
prettyqt.widgets.graphicsitem
The base class for all graphical items in a QGraphicsScene.
    GraphicsItemGroup
    prettyqt.widgets.graphicsitemgroup
    Container that treats a group of items as a single item.
      AbstractGraphicsShapeItemMixin
      prettyqt.widgets.abstractgraphicsshapeitem
      GraphicsPixmapItem
      prettyqt.widgets.graphicspixmapitem
      Pixmap item that you can add to a QGraphicsScene.
        GraphicsObjectMixin
        prettyqt.widgets.graphicsobject
        GraphicsLineItem
        prettyqt.widgets.graphicslineitem
        Line item that you can add to a QGraphicsScene.

          🛈 DocStrings

          Bases: _GraphicsItemBase

          Source code in prettyqt/widgets/graphicsitem.py
          class GraphicsItemMixin(_GraphicsItemBase):
              def __repr__(self):
                  return get_repr(self)
          
              def __contains__(self, value: QtCore.QPointF) -> bool:
                  return self.contains(value)
          
              def __getitem__(self, key: int):
                  return self.data(key)
          
              def __setitem__(self, key: int, value):
                  self.setData(key, value)
          
              def set_focus(
                  self, reason: constants.FocusReasonStr | constants.FocusReason = "other"
              ):
                  self.setFocus(constants.FOCUS_REASONS.get_enum_value(reason))
          
              def colliding_items(
                  self,
                  mode: constants.ItemSelectionModeStr
                  | constants.ItemSelectionMode = "intersects_shape",
              ) -> listdelegators.ListDelegator[QtWidgets.QGraphicsItem]:
                  items = self.collidingItems(constants.ITEM_SELECTION_MODE.get_enum_value(mode))
                  return listdelegators.ListDelegator(items)
          
              def collides_with(
                  self,
                  item: gui.QPainterPath | QtWidgets.QGraphicsItem,
                  mode: constants.ItemSelectionModeStr
                  | constants.ItemSelectionMode = "intersects_shape",
              ) -> bool:
                  if isinstance(item, gui.QPainterPath):
                      return self.collidesWithPath(
                          item, constants.ITEM_SELECTION_MODE.get_enum_value(mode)
                      )
                  return self.collidesWithItem(
                      item, constants.ITEM_SELECTION_MODE.get_enum_value(mode)
                  )
          
              def set_panel_modality(
                  self, modality: PanelModalityStr | QtWidgets.QGraphicsItem.PanelModality
              ):
                  """Set panel modality.
          
                  Args:
                      modality: panel modality
                  """
                  self.setPanelModality(PANEL_MODALITY.get_enum_value(modality))
          
              def get_panel_modality(self) -> PanelModalityStr:
                  """Get the current modality modes as a string.
          
                  Returns:
                      panel modality
                  """
                  return PANEL_MODALITY.inverse[self.panelModality()]
          
              def set_cache_mode(self, mode: CacheModeStr | QtWidgets.QGraphicsItem.CacheMode):
                  """Set cache mode.
          
                  Args:
                      mode: cache mode
                  """
                  self.setCacheMode(CACHE_MODE.get_enum_value(mode))
          
              def get_cache_mode(self) -> CacheModeStr:
                  """Get the current mode modes as a string.
          
                  Returns:
                      cache mode
                  """
                  return CACHE_MODE.inverse[self.cacheMode()]
          
              def get_shape(self) -> gui.PainterPath:
                  return gui.PainterPath(self.shape())
          
              def set_scale(self, scale: tuple[float, float] | float):
                  if isinstance(scale, int | float):
                      self.setScale(scale)
                  else:
                      self.setTransform(gui.Transform.fromScale(scale[0], scale[1]), True)
          
              def set_transform(self, transform: datatypes.TransformType, combine: bool = False):
                  if isinstance(transform, tuple):
                      transform = gui.Transform(*transform)
                  self.setTransform(transform, combine)
          

          get_cache_mode() -> CacheModeStr

          Get the current mode modes as a string.

          Source code in prettyqt/widgets/graphicsitem.py
          def get_cache_mode(self) -> CacheModeStr:
              """Get the current mode modes as a string.
          
              Returns:
                  cache mode
              """
              return CACHE_MODE.inverse[self.cacheMode()]
          

          get_panel_modality() -> PanelModalityStr

          Get the current modality modes as a string.

          Source code in prettyqt/widgets/graphicsitem.py
          def get_panel_modality(self) -> PanelModalityStr:
              """Get the current modality modes as a string.
          
              Returns:
                  panel modality
              """
              return PANEL_MODALITY.inverse[self.panelModality()]
          

          set_cache_mode(mode: CacheModeStr | QtWidgets.QGraphicsItem.CacheMode)

          Set cache mode.

          Parameters:

          Name Type Description Default
          mode CacheModeStr | CacheMode

          cache mode

          required
          Source code in prettyqt/widgets/graphicsitem.py
          def set_cache_mode(self, mode: CacheModeStr | QtWidgets.QGraphicsItem.CacheMode):
              """Set cache mode.
          
              Args:
                  mode: cache mode
              """
              self.setCacheMode(CACHE_MODE.get_enum_value(mode))
          

          set_panel_modality(modality: PanelModalityStr | QtWidgets.QGraphicsItem.PanelModality)

          Set panel modality.

          Parameters:

          Name Type Description Default
          modality PanelModalityStr | PanelModality

          panel modality

          required
          Source code in prettyqt/widgets/graphicsitem.py
          def set_panel_modality(
              self, modality: PanelModalityStr | QtWidgets.QGraphicsItem.PanelModality
          ):
              """Set panel modality.
          
              Args:
                  modality: panel modality
              """
              self.setPanelModality(PANEL_MODALITY.get_enum_value(modality))
          

          :fa-brands-github: Show source on GitHub