Gtk.TextTag

g GObject.Object GObject.Object Gtk.TextTag Gtk.TextTag GObject.Object->Gtk.TextTag

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (name)

changed (size_changed)

get_priority ()

set_priority (priority)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

accumulative-margin

bool

r/w

allow-breaks

bool

r/w

allow-breaks-set

bool

r/w

background

str

w

background-full-height

bool

r/w

background-full-height-set

bool

r/w

background-rgba

Gdk.RGBA

r/w

background-set

bool

r/w

direction

Gtk.TextDirection

r/w

editable

bool

r/w

editable-set

bool

r/w

fallback

bool

r/w

fallback-set

bool

r/w

family

str

r/w

family-set

bool

r/w

font

str

r/w

font-desc

Pango.FontDescription

r/w

font-features

str

r/w

font-features-set

bool

r/w

foreground

str

w

foreground-rgba

Gdk.RGBA

r/w

foreground-set

bool

r/w

indent

int

r/w

indent-set

bool

r/w

insert-hyphens

bool

r/w

insert-hyphens-set

bool

r/w

invisible

bool

r/w

invisible-set

bool

r/w

justification

Gtk.Justification

r/w

justification-set

bool

r/w

language

str

r/w

language-set

bool

r/w

left-margin

int

r/w

left-margin-set

bool

r/w

letter-spacing

int

r/w

letter-spacing-set

bool

r/w

line-height

float

r/w

line-height-set

bool

r/w

name

str

r/w/co

overline

Pango.Overline

r/w

overline-rgba

Gdk.RGBA

r/w

overline-rgba-set

bool

r/w

overline-set

bool

r/w

paragraph-background

str

w

paragraph-background-rgba

Gdk.RGBA

r/w

paragraph-background-set

bool

r/w

pixels-above-lines

int

r/w

pixels-above-lines-set

bool

r/w

pixels-below-lines

int

r/w

pixels-below-lines-set

bool

r/w

pixels-inside-wrap

int

r/w

pixels-inside-wrap-set

bool

r/w

right-margin

int

r/w

right-margin-set

bool

r/w

rise

int

r/w

rise-set

bool

r/w

scale

float

r/w

scale-set

bool

r/w

sentence

bool

r/w

sentence-set

bool

r/w

show-spaces

Pango.ShowFlags

r/w

show-spaces-set

bool

r/w

size

int

r/w

size-points

float

r/w

size-set

bool

r/w

stretch

Pango.Stretch

r/w

stretch-set

bool

r/w

strikethrough

bool

r/w

strikethrough-rgba

Gdk.RGBA

r/w

strikethrough-rgba-set

bool

r/w

strikethrough-set

bool

r/w

style

Pango.Style

r/w

style-set

bool

r/w

tabs

Pango.TabArray

r/w

tabs-set

bool

r/w

text-transform

Pango.TextTransform

r/w

text-transform-set

bool

r/w

underline

Pango.Underline

r/w

underline-rgba

Gdk.RGBA

r/w

underline-rgba-set

bool

r/w

underline-set

bool

r/w

variant

Pango.Variant

r/w

variant-set

bool

r/w

weight

int

r/w

weight-set

bool

r/w

word

bool

r/w

word-set

bool

r/w

wrap-mode

Gtk.WrapMode

r/w

wrap-mode-set

bool

r/w

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Gtk.TextTag(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.TextTagClass

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 [class`Gtk`.TextTagTable] for a given GtkTextBuffer before using them with that buffer.

[method`Gtk`.TextBuffer.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.

classmethod new(name)[source]
Parameters:

name (str or None) – tag name

Returns:

a new GtkTextTag

Return type:

Gtk.TextTag

Creates a GtkTextTag.

changed(size_changed)[source]
Parameters:

size_changed (bool) – whether the change affects the GtkTextView layout

Emits the [signal`Gtk`.TextTagTable::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.

get_priority()[source]
Returns:

The tag’s priority.

Return type:

int

Get the tag priority.

set_priority(priority)[source]
Parameters:

priority (int) – the new priority

Sets the priority of a GtkTextTag.

Valid priorities start at 0 and go to one less than [method`Gtk`.TextTagTable.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 [method`Gtk`.TextBuffer.create_tag], which adds the tag to the buffer’s table automatically.

Property Details

Gtk.TextTag.props.accumulative_margin
Name:

accumulative-margin

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

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).

Gtk.TextTag.props.allow_breaks
Name:

allow-breaks

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

Whether breaks are allowed.

Gtk.TextTag.props.allow_breaks_set
Name:

allow-breaks-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the allow-breaks property is set.

Gtk.TextTag.props.background
Name:

background

Type:

str

Default Value:

None

Flags:

WRITABLE

Background color as a string.

Gtk.TextTag.props.background_full_height
Name:

background-full-height

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

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

Gtk.TextTag.props.background_full_height_set
Name:

background-full-height-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the background-full-height property is set.

Gtk.TextTag.props.background_rgba
Name:

background-rgba

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE, WRITABLE

Background color as a GdkRGBA.

Gtk.TextTag.props.background_set
Name:

background-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the background property is set.

Gtk.TextTag.props.direction
Name:

direction

Type:

Gtk.TextDirection

Default Value:

Gtk.TextDirection.NONE

Flags:

READABLE, WRITABLE

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

Gtk.TextTag.props.editable
Name:

editable

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

Whether the text can be modified by the user.

Gtk.TextTag.props.editable_set
Name:

editable-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the editable property is set.

Gtk.TextTag.props.fallback
Name:

fallback

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

Whether font fallback is enabled.

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

Gtk.TextTag.props.fallback_set
Name:

fallback-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the fallback property is set.

Gtk.TextTag.props.family
Name:

family

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

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

Gtk.TextTag.props.family_set
Name:

family-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the family property is set.

Gtk.TextTag.props.font
Name:

font

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

Font description as string, e.g. \”Sans Italic 12\”.

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

Gtk.TextTag.props.font_desc
Name:

font-desc

Type:

Pango.FontDescription

Default Value:

None

Flags:

READABLE, WRITABLE

Font description as a PangoFontDescription.

Gtk.TextTag.props.font_features
Name:

font-features

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

OpenType font features, as a string.

Gtk.TextTag.props.font_features_set
Name:

font-features-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the font-features property is set.

Gtk.TextTag.props.foreground
Name:

foreground

Type:

str

Default Value:

None

Flags:

WRITABLE

Foreground color as a string.

Gtk.TextTag.props.foreground_rgba
Name:

foreground-rgba

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE, WRITABLE

Foreground color as a GdkRGBA.

Gtk.TextTag.props.foreground_set
Name:

foreground-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the foreground property is set.

Gtk.TextTag.props.indent
Name:

indent

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

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.

Gtk.TextTag.props.indent_set
Name:

indent-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the indent property is set.

Gtk.TextTag.props.insert_hyphens
Name:

insert-hyphens

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

Whether to insert hyphens at breaks.

Gtk.TextTag.props.insert_hyphens_set
Name:

insert-hyphens-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the insert-hyphens property is set.

Gtk.TextTag.props.invisible
Name:

invisible

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

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.

Gtk.TextTag.props.invisible_set
Name:

invisible-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the invisible property is set.

Gtk.TextTag.props.justification
Name:

justification

Type:

Gtk.Justification

Default Value:

Gtk.Justification.LEFT

Flags:

READABLE, WRITABLE

Left, right, or center justification.

Gtk.TextTag.props.justification_set
Name:

justification-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the justification property is set.

Gtk.TextTag.props.language
Name:

language

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

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 [func`Gtk`.get_default_language].

Gtk.TextTag.props.language_set
Name:

language-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the language property is set.

Gtk.TextTag.props.left_margin
Name:

left-margin

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Width of the left margin in pixels.

Gtk.TextTag.props.left_margin_set
Name:

left-margin-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the left-margin property is set.

Gtk.TextTag.props.letter_spacing
Name:

letter-spacing

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Extra spacing between graphemes, in Pango units.

Gtk.TextTag.props.letter_spacing_set
Name:

letter-spacing-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the letter-spacing property is set.

Gtk.TextTag.props.line_height
Name:

line-height

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

Factor to scale line height by.

New in version 4.6.

Gtk.TextTag.props.line_height_set
Name:

line-height-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the line-height property is set.

Gtk.TextTag.props.name
Name:

name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The name used to refer to the tag.

None for anonymous tags.

Gtk.TextTag.props.overline
Name:

overline

Type:

Pango.Overline

Default Value:

Pango.Overline.NONE

Flags:

READABLE, WRITABLE

Style of overline for this text.

Gtk.TextTag.props.overline_rgba
Name:

overline-rgba

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE, WRITABLE

This property modifies the color of overlines.

If not set, overlines will use the foreground color.

Gtk.TextTag.props.overline_rgba_set
Name:

overline-rgba-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the overline-rgba property is set.

Gtk.TextTag.props.overline_set
Name:

overline-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the overline property is set.

Gtk.TextTag.props.paragraph_background
Name:

paragraph-background

Type:

str

Default Value:

None

Flags:

WRITABLE

The paragraph background color as a string.

Gtk.TextTag.props.paragraph_background_rgba
Name:

paragraph-background-rgba

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE, WRITABLE

The paragraph background color as a GdkRGBA.

Gtk.TextTag.props.paragraph_background_set
Name:

paragraph-background-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the paragraph-background property is set.

Gtk.TextTag.props.pixels_above_lines
Name:

pixels-above-lines

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Pixels of blank space above paragraphs.

Gtk.TextTag.props.pixels_above_lines_set
Name:

pixels-above-lines-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the pixels-above-lines property is set.

Gtk.TextTag.props.pixels_below_lines
Name:

pixels-below-lines

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Pixels of blank space below paragraphs.

Gtk.TextTag.props.pixels_below_lines_set
Name:

pixels-below-lines-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the pixels-below-lines property is set.

Gtk.TextTag.props.pixels_inside_wrap
Name:

pixels-inside-wrap

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Pixels of blank space between wrapped lines in a paragraph.

Gtk.TextTag.props.pixels_inside_wrap_set
Name:

pixels-inside-wrap-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the pixels-inside-wrap property is set.

Gtk.TextTag.props.right_margin
Name:

right-margin

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Width of the right margin, in pixels.

Gtk.TextTag.props.right_margin_set
Name:

right-margin-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the right-margin property is set.

Gtk.TextTag.props.rise
Name:

rise

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Offset of text above the baseline, in Pango units.

Negative values go below the baseline.

Gtk.TextTag.props.rise_set
Name:

rise-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the rise property is set.

Gtk.TextTag.props.scale
Name:

scale

Type:

float

Default Value:

1.0

Flags:

READABLE, WRITABLE

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.

Gtk.TextTag.props.scale_set
Name:

scale-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the scale property is set.

Gtk.TextTag.props.sentence
Name:

sentence

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether this tag represents a single sentence.

This affects cursor movement.

New in version 4.6.

Gtk.TextTag.props.sentence_set
Name:

sentence-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the sentence property is set.

Gtk.TextTag.props.show_spaces
Name:

show-spaces

Type:

Pango.ShowFlags

Default Value:

Pango.ShowFlags.NONE

Flags:

READABLE, WRITABLE

How to render invisible characters.

Gtk.TextTag.props.show_spaces_set
Name:

show-spaces-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the show-spaces property is set.

Gtk.TextTag.props.size
Name:

size

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Font size in Pango units.

Gtk.TextTag.props.size_points
Name:

size-points

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

Font size in points.

Gtk.TextTag.props.size_set
Name:

size-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the size property is set.

Gtk.TextTag.props.stretch
Name:

stretch

Type:

Pango.Stretch

Default Value:

Pango.Stretch.NORMAL

Flags:

READABLE, WRITABLE

Font stretch as a PangoStretch, e.g. Pango.Stretch.CONDENSED.

Gtk.TextTag.props.stretch_set
Name:

stretch-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the stretch property is set.

Gtk.TextTag.props.strikethrough
Name:

strikethrough

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether to strike through the text.

Gtk.TextTag.props.strikethrough_rgba
Name:

strikethrough-rgba

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE, WRITABLE

This property modifies the color of strikeouts.

If not set, strikeouts will use the foreground color.

Gtk.TextTag.props.strikethrough_rgba_set
Name:

strikethrough-rgba-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the strikethrough-rgba property has been set.

Gtk.TextTag.props.strikethrough_set
Name:

strikethrough-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the strikethrough property is set.

Gtk.TextTag.props.style
Name:

style

Type:

Pango.Style

Default Value:

Pango.Style.NORMAL

Flags:

READABLE, WRITABLE

Font style as a PangoStyle, e.g. Pango.Style.ITALIC.

Gtk.TextTag.props.style_set
Name:

style-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the style property is set.

Gtk.TextTag.props.tabs
Name:

tabs

Type:

Pango.TabArray

Default Value:

None

Flags:

READABLE, WRITABLE

Custom tabs for this text.

Gtk.TextTag.props.tabs_set
Name:

tabs-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the tabs property is set.

Gtk.TextTag.props.text_transform
Name:

text-transform

Type:

Pango.TextTransform

Default Value:

Pango.TextTransform.NONE

Flags:

READABLE, WRITABLE

How to transform the text for display.

New in version 4.6.

Gtk.TextTag.props.text_transform_set
Name:

text-transform-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the text-transform property is set.

Gtk.TextTag.props.underline
Name:

underline

Type:

Pango.Underline

Default Value:

Pango.Underline.NONE

Flags:

READABLE, WRITABLE

Style of underline for this text.

Gtk.TextTag.props.underline_rgba
Name:

underline-rgba

Type:

Gdk.RGBA

Default Value:

None

Flags:

READABLE, WRITABLE

This property modifies the color of underlines.

If not set, underlines will use the foreground color.

If [property`Gtk`.TextTag: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.

Gtk.TextTag.props.underline_rgba_set
Name:

underline-rgba-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the underline-rgba property has been set.

Gtk.TextTag.props.underline_set
Name:

underline-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the underline property is set.

Gtk.TextTag.props.variant
Name:

variant

Type:

Pango.Variant

Default Value:

Pango.Variant.NORMAL

Flags:

READABLE, WRITABLE

Font variant as a PangoVariant, e.g. Pango.Variant.SMALL_CAPS.

Gtk.TextTag.props.variant_set
Name:

variant-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the variant property is set.

Gtk.TextTag.props.weight
Name:

weight

Type:

int

Default Value:

400

Flags:

READABLE, WRITABLE

Font weight as an integer.

Gtk.TextTag.props.weight_set
Name:

weight-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the weight property is set.

Gtk.TextTag.props.word
Name:

word

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether this tag represents a single word.

This affects line breaks and cursor movement.

New in version 4.6.

Gtk.TextTag.props.word_set
Name:

word-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the word property is set.

Gtk.TextTag.props.wrap_mode
Name:

wrap-mode

Type:

Gtk.WrapMode

Default Value:

Gtk.WrapMode.NONE

Flags:

READABLE, WRITABLE

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

Gtk.TextTag.props.wrap_mode_set
Name:

wrap-mode-set

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the wrap-mode property is set.