TextTag
-
class TextTag(**properties: Any)
Superclasses: Object
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
Whether the allow-breaks property is set.
-
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
Whether the background-full-height property is set.
-
props.background_rgba: RGBA
Background color as a GdkRGBA.
-
props.background_set: bool
Whether the background property is set.
-
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
Whether the editable property is set.
-
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
Whether the fallback property is set.
-
props.family: str
Name of the font family, e.g. Sans, Helvetica, Times, Monospace.
-
props.family_set: bool
Whether the family property is set.
-
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
Whether the font-features property is set.
-
props.foreground: str
Foreground color as a string.
-
props.foreground_rgba: RGBA
Foreground color as a GdkRGBA.
-
props.foreground_set: bool
Whether the foreground property is set.
-
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
Whether the indent property is set.
-
props.insert_hyphens: bool
Whether to insert hyphens at breaks.
-
props.insert_hyphens_set: bool
Whether the insert-hyphens property is set.
-
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
Whether the invisible property is set.
-
props.justification: Justification
Left, right, or center justification.
-
props.justification_set: bool
Whether the justification property is set.
-
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
Whether the language property is set.
-
props.left_margin: int
Width of the left margin in pixels.
-
props.left_margin_set: bool
Whether the left-margin property is set.
-
props.letter_spacing: int
Extra spacing between graphemes, in Pango units.
-
props.letter_spacing_set: bool
Whether the letter-spacing property is set.
-
props.line_height: float
Factor to scale line height by.
-
props.line_height_set: bool
Whether the line-height property is set.
-
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
Whether the overline-rgba property is set.
-
props.overline_set: bool
Whether the overline property is set.
-
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
Whether the paragraph-background property is set.
-
props.pixels_above_lines: int
Pixels of blank space above paragraphs.
-
props.pixels_above_lines_set: bool
Whether the pixels-above-lines property is set.
-
props.pixels_below_lines: int
Pixels of blank space below paragraphs.
-
props.pixels_below_lines_set: bool
Whether the pixels-below-lines property is set.
-
props.pixels_inside_wrap: int
Pixels of blank space between wrapped lines in a paragraph.
-
props.pixels_inside_wrap_set: bool
Whether the pixels-inside-wrap property is set.
-
props.right_margin: int
Width of the right margin, in pixels.
-
props.right_margin_set: bool
Whether the right-margin property is set.
-
props.rise: int
Offset of text above the baseline, in Pango units.
Negative values go below the baseline.
-
props.rise_set: bool
Whether the rise property is set.
-
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
Whether the scale property is set.
-
props.sentence: bool
Whether this tag represents a single sentence.
This affects cursor movement.
-
props.sentence_set: bool
Whether the sentence property is set.
-
props.show_spaces: ShowFlags
How to render invisible characters.
-
props.show_spaces_set: bool
Whether the show-spaces property is set.
-
props.size: int
Font size in Pango units.
-
props.size_points: float
Font size in points.
-
props.size_set: bool
Whether the size property is set.
-
props.stretch: Stretch
Font stretch as a PangoStretch, e.g. %PANGO_STRETCH_CONDENSED.
-
props.stretch_set: bool
Whether the stretch property is set.
-
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
Whether the strikethrough property is set.
-
props.style: Style
Font style as a PangoStyle, e.g. %PANGO_STYLE_ITALIC.
-
props.style_set: bool
Whether the style property is set.
-
props.tabs: TabArray
Custom tabs for this text.
-
props.tabs_set: bool
Whether the tabs property is set.
-
props.text_transform: TextTransform
How to transform the text for display.
-
props.text_transform_set: bool
Whether the text-transform property is set.
-
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
Whether the underline property is set.
-
props.variant: Variant
Font variant as a PangoVariant, e.g. %PANGO_VARIANT_SMALL_CAPS.
-
props.variant_set: bool
Whether the variant property is set.
-
props.weight: int
Font weight as an integer.
-
props.weight_set: bool
Whether the weight property is set.
-
props.word: bool
Whether this tag represents a single word.
This affects line breaks and cursor movement.
-
props.word_set: bool
Whether the word property is set.
-
props.wrap_mode: WrapMode
Whether to wrap lines never, at word boundaries, or
at character boundaries.
-
props.wrap_mode_set: bool
Whether the wrap-mode property is set.
Fields
-
class TextTag
-
parent_instance
-
priv