Class: QgsTextFormatWidget¶
A widget for customizing text formatting settings.
QgsTextFormatWidget provides a widget for controlling the
appearance of text rendered using QgsTextRenderer. The
widget includes all settings contained within a
QgsTextFormat, including shadow, background and buffer.
Additionally, the widget can handle labeling settings due to the large
overlap between the text renderer settings and the labeling settings.
This mode is possible by subclassing QgsTextFormatWidget and
calling the protected constructor with a mode of Labeling.
Class Hierarchy¶
Base classes¶
Abstract interface for generating an expression context. |
- class qgis.gui.QgsTextFormatWidget[source]¶
Bases:
QWidget,QgsExpressionContextGenerator- __init__(format: QgsTextFormat = QgsTextFormat(), mapCanvas: QgsMapCanvas | None = None, parent: QWidget | None = None, layer: QgsMapLayer | None = None)
Constructor for QgsTextFormatWidget.
- Parameters:
format (
QgsTextFormat= QgsTextFormat()) – initial formatting settings to show in widgetmapCanvas (Optional[QgsMapCanvas] = None) – associated map canvas
parent (Optional[QWidget] = None) – parent widget
layer (Optional[QgsMapLayer] = None) – associated layer (vector or mesh)
- __init__(mapCanvas: QgsMapCanvas | None, parent: QWidget | None, mode: QgsTextFormatWidget.Mode, layer: QgsMapLayer | None = None)
Constructor for QgsTextFormatWidget.
- Parameters:
mapCanvas (Optional[QgsMapCanvas]) – associated map canvas
parent (Optional[QWidget]) – parent widget
mode (QgsTextFormatWidget.Mode) – widget mode
layer (Optional[QgsMapLayer] = None) – associated vector layer
- Labeling = 1¶
- class Mode¶
Bases:
int
- Text = 0¶
- signal auxiliaryFieldCreated[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- context(self) QgsSymbolWidgetContext[source]¶
Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts.
See also
Added in version 3.10.
- Return type:
- deactivateField(self, key: QgsPalLayerSettings.Property)[source]¶
Deactivate a field from data defined properties and update the corresponding button.
- Parameters:
key (QgsPalLayerSettings.Property) – The property key to deactivate
- enableDataDefinedAlignment(self, enable: bool)[source]¶
Update the enabled state of the data defined alignment buttons.
Deprecated since version 3.24.
- Parameters:
enable (bool)
- format(self, includeDataDefinedProperties: bool = True) QgsTextFormat[source]¶
Returns the current formatting settings defined by the widget.
If
includateDataDefinedPropertiesisTrue, then data defined properties specified in the widget will be included in the format definition.- Parameters:
includeDataDefinedProperties (bool = True)
- Return type:
- labelGeometryType(self) Qgis.GeometryType[source]¶
Returns the geometry type which will be used by the labeling engine when registering labels for the labeling settings currently defined by the widget.
Added in version 3.16.
- Return type:
- virtual setContext(self, context: QgsSymbolWidgetContext)[source]¶
Sets the
contextin which the widget is shown, e.g., the associated map canvas and expression contexts.See also
Added in version 3.10.
- Parameters:
context (QgsSymbolWidgetContext)
- setDockMode(self, enabled: bool)[source]¶
Sets whether the widget should be shown in a compact dock mode.
- Parameters:
enabled (bool) – set to
Trueto show in dock mode.
- setFormat(self, format: QgsTextFormat)[source]¶
Sets the current formatting settings
Added in version 3.2.
- Parameters:
format (QgsTextFormat)
- virtual setFormatFromStyle(self, name: str | None, type: QgsStyle.StyleEntity, stylePath: str | None)[source]¶
Sets the current text settings from a style entry.
Added in version 3.10.
- Parameters:
name (Optional[str])
type (QgsStyle.StyleEntity)
stylePath (Optional[str])
- setPreviewBackground(self, color: QColor | Qt.GlobalColor)[source]¶
Sets the background color for the text preview widget.
- Parameters:
color (Union[QColor, Qt.GlobalColor]) – background color
- setPropertyOverrideButtonsVisible(self, visible: bool)[source]¶
Toggles whether data defined buttons should be shown in the widget.
Added in version 3.42.
- Parameters:
visible (bool)
- updateLinePlacementOptions(self)[source]¶
Updates line placement options to reflect current state of widget
- updatePlacementWidgets(self)[source]¶
Updates label placement options to reflect current state of widget
- updateWidgetForFormat(self, format: QgsTextFormat)[source]¶
Updates the widget’s state to reflect the settings in a
QgsTextFormat.- Parameters:
format (QgsTextFormat) – source format
- signal widgetChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.