Skip to content

drawing

drawing

DrawingML-related objects are in this subpackage.

Drawing

Drawing(drawing: CT_Drawing, parent: ProvidesStoryPart)

Bases: Parented

Container for a DrawingML object.

Source code in src/docx/drawing/__init__.py
def __init__(self, drawing: CT_Drawing, parent: t.ProvidesStoryPart):
    super().__init__(parent)
    self._parent = parent
    self._drawing = self._element = drawing

has_picture property

has_picture: bool

True when drawing contains an embedded picture.

A drawing can contain a picture, but it can also contain a chart, SmartArt, or a drawing canvas. Methods related to a picture, like .image, will raise when the drawing does not contain a picture. Use this value to determine whether image methods will succeed.

This value is False when a linked picture is present. This should be relatively rare and the image would only be retrievable from the filesystem.

Note this does not distinguish between inline and floating images. The presence of either one will cause this value to be True.

image property

image: Image

An Image proxy object for the image in this (picture) drawing.

Raises ValueError when this drawing does contains something other than a picture. Use .has_picture to qualify drawing objects before using this property.