Skip to content

GraphicsPixmapItem

Base classes

Name Children Inherits
GraphicsItemMixin
prettyqt.widgets.graphicsitem
QGraphicsPixmapItem
PySide6.QtWidgets
QGraphicsPixmapItem(self, pixmap: PySide6.QtGui.QPixmap | PySide6.QtGui.QImage, /, parent: PySide6.QtWidgets.QGraphicsItem | None \= None) -> None

⋔ Inheritance diagram

graph TD
  1649920864["widgets.GraphicsPixmapItem"]
  1638127052["widgets.GraphicsItemMixin"]
  2751680898["builtins.object"]
  3403337318["QtWidgets.QGraphicsPixmapItem"]
  2584426969["QtWidgets.QGraphicsItem"]
  37984305["Shiboken.Object"]
  1638127052 --> 1649920864
  2751680898 --> 1638127052
  3403337318 --> 1649920864
  2584426969 --> 3403337318
  37984305 --> 2584426969
  2751680898 --> 37984305

🛈 DocStrings

Bases: GraphicsItemMixin, QGraphicsPixmapItem

Pixmap item that you can add to a QGraphicsScene.

Source code in prettyqt/widgets/graphicspixmapitem.py
class GraphicsPixmapItem(widgets.GraphicsItemMixin, widgets.QGraphicsPixmapItem):
    """Pixmap item that you can add to a QGraphicsScene."""

    def set_transformation_mode(
        self, mode: constants.TransformationModeStr | constants.TransformationMode
    ):
        """Set transformation mode.

        Args:
            mode: transformation mode to use
        """
        self.setTransformationMode(constants.TRANSFORMATION_MODE.get_enum_value(mode))

    def get_transformation_mode(self) -> constants.TransformationModeStr:
        """Return current transformation mode.

        Returns:
            transformation mode
        """
        return constants.TRANSFORMATION_MODE.inverse[self.transformationMode()]

    def set_shape_mode(self, mode: ShapeModeStr | widgets.QGraphicsPixmapItem.ShapeMode):
        """Set shape mode.

        Args:
            mode: shape mode to use
        """
        self.setShapeMode(SHAPE_MODE.get_enum_value(mode))

    def get_shape_mode(self) -> ShapeModeStr:
        """Return current shape mode.

        Returns:
            shape mode
        """
        return SHAPE_MODE.inverse[self.shapeMode()]

    def get_pixmap(self) -> gui.Pixmap | None:
        pix = self.pixmap()
        return None if pix.isNull() else gui.Pixmap(pix)

get_shape_mode() -> ShapeModeStr

Return current shape mode.

Source code in prettyqt/widgets/graphicspixmapitem.py
def get_shape_mode(self) -> ShapeModeStr:
    """Return current shape mode.

    Returns:
        shape mode
    """
    return SHAPE_MODE.inverse[self.shapeMode()]

get_transformation_mode() -> constants.TransformationModeStr

Return current transformation mode.

Source code in prettyqt/widgets/graphicspixmapitem.py
def get_transformation_mode(self) -> constants.TransformationModeStr:
    """Return current transformation mode.

    Returns:
        transformation mode
    """
    return constants.TRANSFORMATION_MODE.inverse[self.transformationMode()]

set_shape_mode(mode: ShapeModeStr | widgets.QGraphicsPixmapItem.ShapeMode)

Set shape mode.

Parameters:

Name Type Description Default
mode ShapeModeStr | ShapeMode

shape mode to use

required
Source code in prettyqt/widgets/graphicspixmapitem.py
def set_shape_mode(self, mode: ShapeModeStr | widgets.QGraphicsPixmapItem.ShapeMode):
    """Set shape mode.

    Args:
        mode: shape mode to use
    """
    self.setShapeMode(SHAPE_MODE.get_enum_value(mode))

set_transformation_mode(mode: constants.TransformationModeStr | constants.TransformationMode)

Set transformation mode.

Parameters:

Name Type Description Default
mode TransformationModeStr | TransformationMode

transformation mode to use

required
Source code in prettyqt/widgets/graphicspixmapitem.py
def set_transformation_mode(
    self, mode: constants.TransformationModeStr | constants.TransformationMode
):
    """Set transformation mode.

    Args:
        mode: transformation mode to use
    """
    self.setTransformationMode(constants.TRANSFORMATION_MODE.get_enum_value(mode))

:fa-brands-github: Show source on GitHub