Class: QgsLayoutItemPicture¶
A layout item subclass that displays SVG files or raster format images (jpg, png, …).
Class Hierarchy¶
Base classes¶
Base class for graphical items within a |
|
A base class for objects which belong to a layout. |
|
Abstract interface for generating an expression context. |
|
Interface for layout objects which support undo/redo commands. |
Enums
alias of |
Methods
Returns the current evaluated picture path, which includes the result of data defined path overrides. |
|
Returns |
|
Returns the linked rotation map, if set. |
|
Returns the current picture mode (image format), FormatUnknown if given picture format is unknown |
|
Returns the mode used to align the picture to a map's North. |
|
Returns the offset added to the picture's rotation from a map's North. |
|
Returns the original set picture mode (image format). |
|
Returns the picture's current anchor, which controls how it is placed within the picture item's frame. |
|
Returns the path of the source image. |
|
Returns the rotation used for drawing the picture within the item's frame, in degrees clockwise. |
|
Forces a recalculation of the picture's frame size |
|
Recalculates the source image (if using an expression for picture's source) and reloads and redraws the picture. |
|
Returns the resize mode used for drawing the picture within the layout item's frame. |
|
Sets the map object for rotation. |
|
Sets the current picture mode (image format). |
|
Sets the mode used to align the picture to a map's North. |
|
Sets the offset added to the picture's rotation from a map's North. |
|
Sets the picture's anchor point, which controls how it is placed within the picture item's frame. |
|
Sets the source path of the image (may be svg or a raster format). |
|
Sets the picture rotation within the item bounds, in degrees clockwise. |
|
Sets the resize mode used for drawing the picture within the item bounds. |
|
Sets the SVG dynamic parameters |
|
Sets the fill color used for parametrized SVG files. |
|
Sets the stroke color used for parametrized SVG files. |
|
Sets the stroke width (in layout units) used for parametrized SVG files. |
|
Returns the SVG dynamic parameters |
|
Returns the fill color used for parametrized SVG files. |
|
Returns the stroke color used for parametrized SVG files. |
|
Returns the stroke width (in layout units) used for parametrized SVG files. |
Static Methods
Returns a new picture item for the specified layout. |
Signals
Emitted on picture rotation change |
Attributes
- class qgis.core.QgsLayoutItemPicture[source]¶
Bases:
QgsLayoutItem
- __init__(layout: QgsLayout | None)
Constructor for QgsLayoutItemPicture, with the specified parent
layout
.- Parameters:
layout (Optional[QgsLayout])
- Clip = 2¶
- Format¶
alias of
PictureFormat
- FrameToImageSize = 4¶
- GridNorth = 0¶
- class NorthMode¶
Bases:
int
- class ResizeMode¶
Bases:
int
- Stretch = 1¶
- TrueNorth = 1¶
- Zoom = 0¶
- ZoomResizeFrame = 3¶
- static create(layout: QgsLayout | None) QgsLayoutItemPicture | None [source]¶
Returns a new picture item for the specified
layout
.The caller takes responsibility for deleting the returned object.
- Parameters:
layout (Optional[QgsLayout])
- Return type:
Optional[QgsLayoutItemPicture]
- evaluatedPath(self) str [source]¶
Returns the current evaluated picture path, which includes the result of data defined path overrides.
See also
Added in version 3.6.
- Return type:
str
- isMissingImage(self) bool [source]¶
Returns
True
if the source image is missing and the picture cannot be rendered.Added in version 3.6.
- Return type:
bool
- linkedMap(self) QgsLayoutItemMap | None [source]¶
Returns the linked rotation map, if set. An
None
means map rotation is disabled. If this is set then the picture is rotated by the same amount as the specified map object.See also
- Return type:
Optional[QgsLayoutItemMap]
- mode(self) Qgis.PictureFormat [source]¶
Returns the current picture mode (image format), FormatUnknown if given picture format is unknown
See also
See also
- Return type:
- northMode(self) QgsLayoutItemPicture.NorthMode [source]¶
Returns the mode used to align the picture to a map’s North.
See also
See also
- Return type:
- northOffset(self) float [source]¶
Returns the offset added to the picture’s rotation from a map’s North.
See also
See also
- Return type:
float
- originalMode(self) Qgis.PictureFormat [source]¶
Returns the original set picture mode (image format). It could differ from
mode()
if given picture format is unknownSee also
See also
Added in version 3.22.
- Return type:
- pictureAnchor(self) QgsLayoutItem.ReferencePoint [source]¶
Returns the picture’s current anchor, which controls how it is placed within the picture item’s frame.
See also
- Return type:
- picturePath(self) str [source]¶
Returns the path of the source image. Data defined picture source may override this value. The path can either be a local path or a remote (http) path.
- Return type:
str
- Returns:
path for the source image
See also
See also
- pictureRotation(self) float [source]¶
Returns the rotation used for drawing the picture within the item’s frame, in degrees clockwise.
See also
See also
- Return type:
float
- signal pictureRotationChanged(newRotation: float)[source]¶
Emitted on picture rotation change
- Parameters:
newRotation (float)
- refreshPicture(self, context: QgsExpressionContext | None = None)[source]¶
Recalculates the source image (if using an expression for picture’s source) and reloads and redraws the picture.
- Parameters:
context (Optional[QgsExpressionContext] = None) – expression context for evaluating data defined picture sources
- resizeMode(self) QgsLayoutItemPicture.ResizeMode [source]¶
Returns the resize mode used for drawing the picture within the layout item’s frame.
See also
- Return type:
- setLinkedMap(self, map: QgsLayoutItemMap | None)[source]¶
Sets the
map
object for rotation.If this is set then the picture will be rotated by the same amount as the specified map object. This is useful especially for syncing north arrows with a map item.
See also
See also
- Parameters:
map (Optional[QgsLayoutItemMap])
- setMode(self, mode: Qgis.PictureFormat)[source]¶
Sets the current picture
mode
(image format).See also
Added in version 3.14.
- Parameters:
mode (Qgis.PictureFormat)
- setNorthMode(self, mode: QgsLayoutItemPicture.NorthMode)[source]¶
Sets the
mode
used to align the picture to a map’s North.See also
See also
- Parameters:
- setNorthOffset(self, offset: float)[source]¶
Sets the
offset
added to the picture’s rotation from a map’s North.See also
See also
- Parameters:
offset (float)
- setPictureAnchor(self, anchor: QgsLayoutItem.ReferencePoint)[source]¶
Sets the picture’s
anchor
point, which controls how it is placed within the picture item’s frame.See also
- Parameters:
anchor (QgsLayoutItem.ReferencePoint)
- setPicturePath(self, path: str | None, format: Qgis.PictureFormat = Qgis.PictureFormat.Unknown)[source]¶
Sets the source
path
of the image (may be svg or a raster format). Data defined picture source may override this value. The path can either be a local path or a remote (http) path.Ideally, the
format
argument should specify the image format.See also
- Parameters:
path (Optional[str])
format (Qgis.PictureFormat = Qgis.PictureFormat.Unknown)
- setPictureRotation(self, rotation: float)[source]¶
Sets the picture
rotation
within the item bounds, in degrees clockwise. This does not affect the item’s frame, only the way the picture is drawn within the item.See also
- Parameters:
rotation (float)
- setResizeMode(self, mode: QgsLayoutItemPicture.ResizeMode)[source]¶
Sets the resize
mode
used for drawing the picture within the item bounds.- Parameters:
mode (QgsLayoutItemPicture.ResizeMode) – ResizeMode to use for image file
See also
- setSvgDynamicParameters(self, parameters: Dict[str | None, QgsProperty])[source]¶
Sets the SVG dynamic parameters
Added in version 3.20.
- Parameters:
parameters (Dict[Optional[str], QgsProperty])
- setSvgFillColor(self, color: QColor | Qt.GlobalColor)[source]¶
Sets the fill
color
used for parametrized SVG files.Note
This setting only has an effect on parametrized SVG files, and is ignored for non-parametrized SVG files.
See also
See also
- Parameters:
color (Union[QColor, Qt.GlobalColor])
- setSvgStrokeColor(self, color: QColor | Qt.GlobalColor)[source]¶
Sets the stroke
color
used for parametrized SVG files.- Parameters:
color (Union[QColor, Qt.GlobalColor]) – stroke color.
Note
This setting only has an effect on parametrized SVG files, and is ignored for non-parametrized SVG files.
See also
See also
- setSvgStrokeWidth(self, width: float)[source]¶
Sets the stroke
width
(in layout units) used for parametrized SVG files.Note
This setting only has an effect on parametrized SVG files, and is ignored for non-parametrized SVG files.
See also
See also
- Parameters:
width (float)
- svgDynamicParameters(self) Dict[str, QgsProperty] ¶
Returns the SVG dynamic parameters
Added in version 3.20.
- Return type:
Dict[str, QgsProperty]
- svgFillColor(self) QColor [source]¶
Returns the fill color used for parametrized SVG files.
See also
See also
- Return type:
QColor
- svgStrokeColor(self) QColor [source]¶
Returns the stroke color used for parametrized SVG files.
See also
See also
- Return type:
QColor