sdt
sdt
¶
The ContentControl proxy object for a structured document tag (w:sdt).
ContentControl
¶
ContentControl(sdt: CT_Sdt, parent: ProvidesStoryPart)
Bases: Parented
Proxy for a w:sdt element, a structured document tag or "content control".
Content controls are what Word uses for form fields in modern documents, for
template placeholders, and for regions bound to a data source. Their content appears
in .paragraphs, .iter_inner_content() and the rest of the read API as though the
wrapper were not there; this object is how the wrapper itself is inspected.
Source code in src/docx/sdt.py
alias
property
¶
The friendly name Word shows on this control, or None if not set.
is_block_level
property
¶
True when this control wraps block-level content.
A block-level control contains paragraphs or tables; a run-level control sits inside a paragraph and contains runs.
paragraphs
property
¶
paragraphs: List[Paragraph]
The paragraphs directly inside this control, in document order.
runs
property
¶
runs: List[Run]
The runs directly inside this control, for a run-level control.
Empty for a block-level control; the runs of such a control are reached through its paragraphs.
showing_placeholder
property
¶
True when this control is currently displaying its placeholder text.
The text of such a control is the prompt shown to the user, not a value they entered, which is worth distinguishing when harvesting values from a form.
tag
property
¶
The programmatic identifier of this control, or None if not set.
Unlike .alias, the tag is not shown to the user; it is what code binding to a
template matches on.
text
property
¶
All the text inside this control.
Paragraphs are separated by newlines, as for a table cell.
type
property
¶
type: WD_CONTENT_CONTROL_TYPE | None
Member of WdContentControlType, or None when the control names no
kind.
Word treats a control with no declared kind as rich text, but that is a default
rather than a statement, so it is reported as None here.
iter_inner_content
¶
Generate each Paragraph or Table in this control, in document order.
Yields nothing for a run-level control; use .runs for one.