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)
  event (event_object, event, iter)
  get_priority ()
  set_priority (priority)

Virtual Methods

Inherited:GObject.Object (7)
  do_event (event_object, event, iter)

Properties

Name Type Flags Short Description
accumulative-margin bool r/w Whether left and right margins accumulate.
background str w Background color as a string
background-full-height bool r/w Whether the background color fills the entire line height or only the height of the tagged characters
background-full-height-set bool r/w Whether this tag affects background height
background-gdk Gdk.Color d/r/w Background color as a Gdk.Color deprecated
background-rgba Gdk.RGBA r/w Background color as a Gdk.RGBA
background-set bool r/w Whether this tag affects the background color
direction Gtk.TextDirection r/w Text direction, e.g. right-to-left or left-to-right
editable bool r/w Whether the text can be modified by the user
editable-set bool r/w Whether this tag affects text editability
fallback bool r/w Whether font fallback is enabled.
fallback-set bool r/w Whether this tag affects font fallback
family str r/w Name of the font family, e.g. Sans, Helvetica, Times, Monospace
family-set bool r/w Whether this tag affects the font family
font str r/w Font description as a string, e.g. “Sans Italic 12”
font-desc Pango.FontDescription r/w Font description as a Pango.FontDescription struct
font-features str r/w OpenType Font Features to use
font-features-set bool r/w Whether this tag affects font features
foreground str w Foreground color as a string
foreground-gdk Gdk.Color d/r/w Foreground color as a Gdk.Color deprecated
foreground-rgba Gdk.RGBA r/w Foreground color as a Gdk.RGBA
foreground-set bool r/w Whether this tag affects the foreground color
indent int r/w Amount to indent the paragraph, in pixels
indent-set bool r/w Whether this tag affects indentation
invisible bool r/w Whether this text is hidden.
invisible-set bool r/w Whether this tag affects text visibility
justification Gtk.Justification r/w Left, right, or center justification
justification-set bool r/w Whether this tag affects paragraph justification
language str r/w 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.
language-set bool r/w Whether this tag affects the language the text is rendered as
left-margin int r/w Width of the left margin in pixels
left-margin-set bool r/w Whether this tag affects the left margin
letter-spacing int r/w Extra spacing between graphemes
letter-spacing-set bool r/w Whether this tag affects letter spacing
name str r/w/co Name used to refer to the text tag. None for anonymous tags
paragraph-background str w Paragraph background color as a string
paragraph-background-gdk Gdk.Color d/r/w Paragraph background color as a Gdk.Color deprecated
paragraph-background-rgba Gdk.RGBA r/w Paragraph background RGBA as a Gdk.RGBA
paragraph-background-set bool r/w Whether this tag affects the paragraph background color
pixels-above-lines int r/w Pixels of blank space above paragraphs
pixels-above-lines-set bool r/w Whether this tag affects the number of pixels above lines
pixels-below-lines int r/w Pixels of blank space below paragraphs
pixels-below-lines-set bool r/w Whether this tag affects the number of pixels above lines
pixels-inside-wrap int r/w Pixels of blank space between wrapped lines in a paragraph
pixels-inside-wrap-set bool r/w Whether this tag affects the number of pixels between wrapped lines
right-margin int r/w Width of the right margin in pixels
right-margin-set bool r/w Whether this tag affects the right margin
rise int r/w Offset of text above the baseline (below the baseline if rise is negative) in Pango units
rise-set bool r/w Whether this tag affects the rise
scale float r/w 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
scale-set bool r/w Whether this tag scales the font size by a factor
size int r/w Font size in Pango units
size-points float r/w Font size in points
size-set bool r/w Whether this tag affects the font size
stretch Pango.Stretch r/w Font stretch as a Pango.Stretch, e.g. Pango.Stretch.CONDENSED
stretch-set bool r/w Whether this tag affects the font stretch
strikethrough bool r/w Whether to strike through the text
strikethrough-rgba Gdk.RGBA r/w Color of strikethrough for this text
strikethrough-rgba-set bool r/w Whether this tag affects strikethrough color
strikethrough-set bool r/w Whether this tag affects strikethrough
style Pango.Style r/w Font style as a Pango.Style, e.g. Pango.Style.ITALIC
style-set bool r/w Whether this tag affects the font style
tabs Pango.TabArray r/w Custom tabs for this text
tabs-set bool r/w Whether this tag affects tabs
underline Pango.Underline r/w Style of underline for this text
underline-rgba Gdk.RGBA r/w Color of underline for this text
underline-rgba-set bool r/w Whether this tag affects underlining color
underline-set bool r/w Whether this tag affects underlining
variant Pango.Variant r/w Font variant as a Pango.Variant, e.g. Pango.Variant.SMALL_CAPS
variant-set bool r/w Whether this tag affects the font variant
weight int r/w Font weight as an integer, see predefined values in Pango.Weight; for example, Pango.Weight.BOLD
weight-set bool r/w Whether this tag affects the font weight
wrap-mode Gtk.WrapMode r/w Whether to wrap lines never, at word boundaries, or at character boundaries
wrap-mode-set bool r/w Whether this tag affects line wrap mode

Signals

Inherited:GObject.Object (1)
Name Short Description
event The ::event signal is emitted when an event occurs on a region of the buffer marked with this tag.

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

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 Gtk.TextTagTable for a given Gtk.TextBuffer before using them with that buffer.

Gtk.TextBuffer.create_tag() is the best way to create tags. See “gtk3-demo” for numerous examples.

For each property of Gtk.TextTag, 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, or None
Returns:a new Gtk.TextTag
Return type:Gtk.TextTag

Creates a Gtk.TextTag. Configure the tag using object arguments, i.e. using g_object_set().

changed(size_changed)[source]
Parameters:size_changed (bool) – whether the change affects the Gtk.TextView layout.

Emits the Gtk.TextTagTable ::tag-changed signal on the Gtk.TextTagTable where the tag is included.

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

New in version 3.20.

event(event_object, event, iter)[source]
Parameters:
  • event_object (GObject.Object) – object that received the event, such as a widget
  • event (Gdk.Event) – the event
  • iter (Gtk.TextIter) – location where the event was received
Returns:

result of signal emission (whether the event was handled)

Return type:

bool

Emits the “event” signal on the Gtk.TextTag.

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

do_event(event_object, event, iter) virtual
Parameters:
  • event_object (GObject.Object) – object that received the event, such as a widget
  • event (Gdk.Event) – the event
  • iter (Gtk.TextIter) – location where the event was received
Returns:

result of signal emission (whether the event was handled)

Return type:

bool

Emits the “event” signal on the Gtk.TextTag.

Signal Details

Gtk.TextTag.signals.event(text_tag, object, event, iter)
Signal Name:

event

Flags:

RUN_LAST

Parameters:
Returns:

True to stop other handlers from being invoked for the event. False to propagate the event further.

Return type:

bool

The ::event signal is emitted when an event occurs on a region of the buffer marked with this tag.

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

New in version 2.12.

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 this tag affects background height

Gtk.TextTag.props.background_gdk
Name:background-gdk
Type:Gdk.Color
Default Value:None
Flags:DEPRECATED, READABLE, WRITABLE

Background color as a Gdk.Color.

Deprecated since version 3.4: Use Gtk.TextTag :background-rgba instead.

Gtk.TextTag.props.background_rgba
Name:background-rgba
Type:Gdk.RGBA
Default Value:None
Flags:READABLE, WRITABLE

Background color as a Gdk.RGBA.

New in version 3.2.

Gtk.TextTag.props.background_set
Name:background-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the background color

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 this tag affects text editability

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.

New in version 3.16.

Gtk.TextTag.props.fallback_set
Name:fallback-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects font fallback

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 this tag affects the font family

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 Pango.FontDescription.

Gtk.TextTag.props.font_desc
Name:font-desc
Type:Pango.FontDescription
Default Value:None
Flags:READABLE, WRITABLE

Font description as a Pango.FontDescription struct

Gtk.TextTag.props.font_features
Name:font-features
Type:str
Default Value:None
Flags:READABLE, WRITABLE

OpenType font features, as a string.

New in version 3.18.

Gtk.TextTag.props.font_features_set
Name:font-features-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects font features

Gtk.TextTag.props.foreground
Name:foreground
Type:str
Default Value:None
Flags:WRITABLE

Foreground color as a string

Gtk.TextTag.props.foreground_gdk
Name:foreground-gdk
Type:Gdk.Color
Default Value:None
Flags:DEPRECATED, READABLE, WRITABLE

Foreground color as a Gdk.Color.

Deprecated since version 3.4: Use Gtk.TextTag :foreground-rgba instead.

Gtk.TextTag.props.foreground_rgba
Name:foreground-rgba
Type:Gdk.RGBA
Default Value:None
Flags:READABLE, WRITABLE

Foreground color as a Gdk.RGBA.

New in version 3.2.

Gtk.TextTag.props.foreground_set
Name:foreground-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the foreground color

Gtk.TextTag.props.indent
Name:indent
Type:int
Default Value:0
Flags:READABLE, WRITABLE

Amount to indent the paragraph, in pixels

Gtk.TextTag.props.indent_set
Name:indent-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects indentation

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.

New in version 2.8.

Gtk.TextTag.props.invisible_set
Name:invisible-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects text visibility

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 this tag affects paragraph justification

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 Gtk.get_default_language().

Gtk.TextTag.props.language_set
Name:language-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the language the text is rendered as

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 this tag affects the left margin

Gtk.TextTag.props.letter_spacing
Name:letter-spacing
Type:int
Default Value:0
Flags:READABLE, WRITABLE

Extra spacing between graphemes, in Pango units.

New in version 3.16.

Gtk.TextTag.props.letter_spacing_set
Name:letter-spacing-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects letter spacing

Gtk.TextTag.props.name
Name:name
Type:str
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

Name used to refer to the text tag. None for anonymous tags

Gtk.TextTag.props.paragraph_background
Name:paragraph-background
Type:str
Default Value:None
Flags:WRITABLE

The paragraph background color as a string.

New in version 2.8.

Gtk.TextTag.props.paragraph_background_gdk
Name:paragraph-background-gdk
Type:Gdk.Color
Default Value:None
Flags:DEPRECATED, READABLE, WRITABLE

The paragraph background color as a Gdk.Color.

New in version 2.8.

Deprecated since version 3.4: Use Gtk.TextTag :paragraph-background-rgba instead.

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 Gdk.RGBA.

New in version 3.2.

Gtk.TextTag.props.paragraph_background_set
Name:paragraph-background-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the paragraph background color

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 this tag affects the number of pixels above lines

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 this tag affects the number of pixels above lines

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 this tag affects the number of pixels between wrapped lines

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 this tag affects the right margin

Gtk.TextTag.props.rise
Name:rise
Type:int
Default Value:0
Flags:READABLE, WRITABLE

Offset of text above the baseline (below the baseline if rise is negative) in Pango units

Gtk.TextTag.props.rise_set
Name:rise-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the rise

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 this tag scales the font size by a factor

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 this tag affects the font size

Gtk.TextTag.props.stretch
Name:stretch
Type:Pango.Stretch
Default Value:Pango.Stretch.NORMAL
Flags:READABLE, WRITABLE

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

Gtk.TextTag.props.stretch_set
Name:stretch-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the font stretch

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 forground color.

New in version 3.16.

Gtk.TextTag.props.strikethrough_rgba_set
Name:strikethrough-rgba-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

If the Gtk.TextTag :strikethrough-rgba property has been set.

New in version 3.16.

Gtk.TextTag.props.strikethrough_set
Name:strikethrough-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects strikethrough

Gtk.TextTag.props.style
Name:style
Type:Pango.Style
Default Value:Pango.Style.NORMAL
Flags:READABLE, WRITABLE

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

Gtk.TextTag.props.style_set
Name:style-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the font style

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 this tag affects tabs

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 forground color.

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

New in version 3.16.

Gtk.TextTag.props.underline_rgba_set
Name:underline-rgba-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

If the Gtk.TextTag :underline-rgba property has been set.

New in version 3.16.

Gtk.TextTag.props.underline_set
Name:underline-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects underlining

Gtk.TextTag.props.variant
Name:variant
Type:Pango.Variant
Default Value:Pango.Variant.NORMAL
Flags:READABLE, WRITABLE

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

Gtk.TextTag.props.variant_set
Name:variant-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the font variant

Gtk.TextTag.props.weight
Name:weight
Type:int
Default Value:400
Flags:READABLE, WRITABLE

Font weight as an integer, see predefined values in Pango.Weight; for example, Pango.Weight.BOLD

Gtk.TextTag.props.weight_set
Name:weight-set
Type:bool
Default Value:False
Flags:READABLE, WRITABLE

Whether this tag affects the font weight

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 this tag affects line wrap mode