TextTag

class TextTag(**properties: Any)

Superclasses: Object

A tag that can be applied to text contained in a GtkTextBuffer.

You may wish to begin by reading the text widget conceptual overview, which gives an overview of all the objects and data types related to the text widget and how they work together.

Tags should be in the TextTagTable for a given GtkTextBuffer before using them with that buffer.

create_tag is the best way to create tags. See “gtk4-demo” for numerous examples.

For each property of GtkTextTag, there is a “set” property, e.g. “font-set” corresponds to “font”. These “set” properties reflect whether a property has been set or not.

They are maintained by GTK and you should not set them independently.

Constructors

class TextTag
classmethod new(name: str | None = None) TextTag

Creates a GtkTextTag.

Parameters:

name – tag name

Methods

class TextTag
changed(size_changed: bool) None

Emits the tag_changed signal on the GtkTextTagTable where the tag is included.

The signal is already emitted when setting a GtkTextTag property. This function is useful for a GtkTextTag subclass.

Parameters:

size_changed – whether the change affects the GtkTextView layout

get_priority() int

Get the tag priority.

set_priority(priority: int) None

Sets the priority of a GtkTextTag.

Valid priorities start at 0 and go to one less than get_size. Each tag in a table has a unique priority; setting the priority of one tag shifts the priorities of all the other tags in the table to maintain a unique priority for each tag.

Higher priority tags “win” if two tags both set the same text attribute. When adding a tag to a tag table, it will be assigned the highest priority in the table by default; so normally the precedence of a set of tags is the order in which they were added to the table, or created with create_tag, which adds the tag to the buffer’s table automatically.

Parameters:

priority – the new priority

Properties

class TextTag
props.accumulative_margin: bool

Whether the margins accumulate or override each other.

When set to True the margins of this tag are added to the margins of any other non-accumulative margins present. When set to False the margins override one another (the default).

props.allow_breaks: bool

Whether breaks are allowed.

props.allow_breaks_set: bool
props.background: str

Background color as a string.

props.background_full_height: bool

Whether the background color fills the entire line height or only the height of the tagged characters.

props.background_full_height_set: bool
props.background_rgba: RGBA

Background color as a GdkRGBA.

props.background_set: bool
props.direction: TextDirection

Text direction, e.g. right-to-left or left-to-right.

props.editable: bool

Whether the text can be modified by the user.

props.editable_set: bool
props.fallback: bool

Whether font fallback is enabled.

When set to True, other fonts will be substituted where the current font is missing glyphs.

props.fallback_set: bool
props.family: str

Name of the font family, e.g. Sans, Helvetica, Times, Monospace.

props.family_set: bool
props.font: str

Font description as string, e.g. "Sans Italic 12".

Note that the initial value of this property depends on the internals of PangoFontDescription.

props.font_desc: FontDescription

Font description as a PangoFontDescription.

props.font_features: str

OpenType font features, as a string.

props.font_features_set: bool
props.foreground: str

Foreground color as a string.

props.foreground_rgba: RGBA

Foreground color as a GdkRGBA.

props.foreground_set: bool
props.indent: int

Amount to indent the paragraph, in pixels.

A negative value of indent will produce a hanging indentation. That is, the first line will have the full width, and subsequent lines will be indented by the absolute value of indent.

props.indent_set: bool
props.insert_hyphens: bool

Whether to insert hyphens at breaks.

props.insert_hyphens_set: bool
props.invisible: bool

Whether this text is hidden.

Note that there may still be problems with the support for invisible text, in particular when navigating programmatically inside a buffer containing invisible segments.

props.invisible_set: bool
props.justification: Justification

Left, right, or center justification.

props.justification_set: bool
props.language: str

The language this text is in, as an ISO code.

Pango can use this as a hint when rendering the text. If not set, an appropriate default will be used.

Note that the initial value of this property depends on the current locale, see also get_default_language.

props.language_set: bool
props.left_margin: int

Width of the left margin in pixels.

props.left_margin_set: bool
props.letter_spacing: int

Extra spacing between graphemes, in Pango units.

props.letter_spacing_set: bool
props.line_height: float

Factor to scale line height by.

Added in version 4.6.

props.line_height_set: bool
props.name: str

The name used to refer to the tag.

None for anonymous tags.

props.overline: Overline

Style of overline for this text.

props.overline_rgba: RGBA

This property modifies the color of overlines.

If not set, overlines will use the foreground color.

props.overline_rgba_set: bool
props.overline_set: bool
props.paragraph_background: str

The paragraph background color as a string.

props.paragraph_background_rgba: RGBA

The paragraph background color as a GdkRGBA.

props.paragraph_background_set: bool
props.pixels_above_lines: int

Pixels of blank space above paragraphs.

props.pixels_above_lines_set: bool
props.pixels_below_lines: int

Pixels of blank space below paragraphs.

props.pixels_below_lines_set: bool
props.pixels_inside_wrap: int

Pixels of blank space between wrapped lines in a paragraph.

props.pixels_inside_wrap_set: bool
props.right_margin: int

Width of the right margin, in pixels.

props.right_margin_set: bool
props.rise: int

Offset of text above the baseline, in Pango units.

Negative values go below the baseline.

props.rise_set: bool
props.scale: float

Font size as a scale factor relative to the default font size.

This properly adapts to theme changes, etc. so is recommended. Pango predefines some scales such as %PANGO_SCALE_X_LARGE.

props.scale_set: bool
props.sentence: bool

Whether this tag represents a single sentence.

This affects cursor movement.

Added in version 4.6.

props.sentence_set: bool
props.show_spaces: ShowFlags

How to render invisible characters.

props.show_spaces_set: bool
props.size: int

Font size in Pango units.

props.size_points: float

Font size in points.

props.size_set: bool
props.stretch: Stretch

Font stretch as a PangoStretch, e.g. %PANGO_STRETCH_CONDENSED.

props.stretch_set: bool
props.strikethrough: bool

Whether to strike through the text.

props.strikethrough_rgba: RGBA

This property modifies the color of strikeouts.

If not set, strikeouts will use the foreground color.

props.strikethrough_rgba_set: bool

If the strikethrough-rgba property has been set.

props.strikethrough_set: bool
props.style: Style

Font style as a PangoStyle, e.g. %PANGO_STYLE_ITALIC.

props.style_set: bool
props.tabs: TabArray

Custom tabs for this text.

props.tabs_set: bool
props.text_transform: TextTransform

How to transform the text for display.

Added in version 4.6.

props.text_transform_set: bool
props.underline: Underline

Style of underline for this text.

props.underline_rgba: RGBA

This property modifies the color of underlines.

If not set, underlines will use the foreground color.

If underline is set to %PANGO_UNDERLINE_ERROR, an alternate color may be applied instead of the foreground. Setting this property will always override those defaults.

props.underline_rgba_set: bool

If the underline-rgba property has been set.

props.underline_set: bool
props.variant: Variant

Font variant as a PangoVariant, e.g. %PANGO_VARIANT_SMALL_CAPS.

props.variant_set: bool
props.weight: int

Font weight as an integer.

props.weight_set: bool
props.word: bool

Whether this tag represents a single word.

This affects line breaks and cursor movement.

Added in version 4.6.

props.word_set: bool
props.wrap_mode: WrapMode

Whether to wrap lines never, at word boundaries, or at character boundaries.

props.wrap_mode_set: bool

Fields

class TextTag
parent_instance
priv