:right-sidebar: True TextTag =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: TextTag(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.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 :obj:`~gi.repository.Gtk.TextTagTable` for a given ``GtkTextBuffer`` before using them with that buffer. :obj:`~gi.repository.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. Constructors ------------ .. rst-class:: interim-class .. class:: TextTag :no-index: .. classmethod:: new(name: str | None = None) -> ~gi.repository.Gtk.TextTag Creates a ``GtkTextTag``. :param name: tag name Methods ------- .. rst-class:: interim-class .. class:: TextTag :no-index: .. method:: changed(size_changed: bool) -> None Emits the :obj:`~gi.repository.Gtk.TextTagTable.signals.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. :param size_changed: whether the change affects the ``GtkTextView`` layout .. method:: get_priority() -> int Get the tag priority. .. method:: set_priority(priority: int) -> None Sets the priority of a ``GtkTextTag``. Valid priorities start at 0 and go to one less than :obj:`~gi.repository.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 :obj:`~gi.repository.Gtk.TextBuffer.create_tag`, which adds the tag to the buffer’s table automatically. :param priority: the new priority Properties ---------- .. rst-class:: interim-class .. class:: TextTag :no-index: .. attribute:: props.accumulative_margin :type: bool Whether the margins accumulate or override each other. When set to :const:`True` the margins of this tag are added to the margins of any other non-accumulative margins present. When set to :const:`False` the margins override one another (the default). .. attribute:: props.allow_breaks :type: bool Whether breaks are allowed. .. attribute:: props.allow_breaks_set :type: bool .. attribute:: props.background :type: str Background color as a string. .. attribute:: props.background_full_height :type: bool Whether the background color fills the entire line height or only the height of the tagged characters. .. attribute:: props.background_full_height_set :type: bool .. attribute:: props.background_rgba :type: ~gi.repository.Gdk.RGBA Background color as a ``GdkRGBA``. .. attribute:: props.background_set :type: bool .. attribute:: props.direction :type: ~gi.repository.Gtk.TextDirection Text direction, e.g. right-to-left or left-to-right. .. attribute:: props.editable :type: bool Whether the text can be modified by the user. .. attribute:: props.editable_set :type: bool .. attribute:: props.fallback :type: bool Whether font fallback is enabled. When set to :const:`True`, other fonts will be substituted where the current font is missing glyphs. .. attribute:: props.fallback_set :type: bool .. attribute:: props.family :type: str Name of the font family, e.g. Sans, Helvetica, Times, Monospace. .. attribute:: props.family_set :type: bool .. attribute:: props.font :type: str Font description as string, e.g. \"Sans Italic 12\". Note that the initial value of this property depends on the internals of ``PangoFontDescription``. .. attribute:: props.font_desc :type: ~gi.repository.Pango.FontDescription Font description as a ``PangoFontDescription``. .. attribute:: props.font_features :type: str OpenType font features, as a string. .. attribute:: props.font_features_set :type: bool .. attribute:: props.foreground :type: str Foreground color as a string. .. attribute:: props.foreground_rgba :type: ~gi.repository.Gdk.RGBA Foreground color as a ``GdkRGBA``. .. attribute:: props.foreground_set :type: bool .. attribute:: props.indent :type: 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. .. attribute:: props.indent_set :type: bool .. attribute:: props.insert_hyphens :type: bool Whether to insert hyphens at breaks. .. attribute:: props.insert_hyphens_set :type: bool .. attribute:: props.invisible :type: 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. .. attribute:: props.invisible_set :type: bool .. attribute:: props.justification :type: ~gi.repository.Gtk.Justification Left, right, or center justification. .. attribute:: props.justification_set :type: bool .. attribute:: props.language :type: 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 :obj:`~gi.repository.Gtk.get_default_language`. .. attribute:: props.language_set :type: bool .. attribute:: props.left_margin :type: int Width of the left margin in pixels. .. attribute:: props.left_margin_set :type: bool .. attribute:: props.letter_spacing :type: int Extra spacing between graphemes, in Pango units. .. attribute:: props.letter_spacing_set :type: bool .. attribute:: props.line_height :type: float Factor to scale line height by. .. versionadded:: 4.6 .. attribute:: props.line_height_set :type: bool .. attribute:: props.name :type: str The name used to refer to the tag. :const:`None` for anonymous tags. .. attribute:: props.overline :type: ~gi.repository.Pango.Overline Style of overline for this text. .. attribute:: props.overline_rgba :type: ~gi.repository.Gdk.RGBA This property modifies the color of overlines. If not set, overlines will use the foreground color. .. attribute:: props.overline_rgba_set :type: bool .. attribute:: props.overline_set :type: bool .. attribute:: props.paragraph_background :type: str The paragraph background color as a string. .. attribute:: props.paragraph_background_rgba :type: ~gi.repository.Gdk.RGBA The paragraph background color as a ``GdkRGBA``. .. attribute:: props.paragraph_background_set :type: bool .. attribute:: props.pixels_above_lines :type: int Pixels of blank space above paragraphs. .. attribute:: props.pixels_above_lines_set :type: bool .. attribute:: props.pixels_below_lines :type: int Pixels of blank space below paragraphs. .. attribute:: props.pixels_below_lines_set :type: bool .. attribute:: props.pixels_inside_wrap :type: int Pixels of blank space between wrapped lines in a paragraph. .. attribute:: props.pixels_inside_wrap_set :type: bool .. attribute:: props.right_margin :type: int Width of the right margin, in pixels. .. attribute:: props.right_margin_set :type: bool .. attribute:: props.rise :type: int Offset of text above the baseline, in Pango units. Negative values go below the baseline. .. attribute:: props.rise_set :type: bool .. attribute:: props.scale :type: 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``. .. attribute:: props.scale_set :type: bool .. attribute:: props.sentence :type: bool Whether this tag represents a single sentence. This affects cursor movement. .. versionadded:: 4.6 .. attribute:: props.sentence_set :type: bool .. attribute:: props.show_spaces :type: ~gi.repository.Pango.ShowFlags How to render invisible characters. .. attribute:: props.show_spaces_set :type: bool .. attribute:: props.size :type: int Font size in Pango units. .. attribute:: props.size_points :type: float Font size in points. .. attribute:: props.size_set :type: bool .. attribute:: props.stretch :type: ~gi.repository.Pango.Stretch Font stretch as a ``PangoStretch``, e.g. ``%PANGO_STRETCH_CONDENSED``. .. attribute:: props.stretch_set :type: bool .. attribute:: props.strikethrough :type: bool Whether to strike through the text. .. attribute:: props.strikethrough_rgba :type: ~gi.repository.Gdk.RGBA This property modifies the color of strikeouts. If not set, strikeouts will use the foreground color. .. attribute:: props.strikethrough_rgba_set :type: bool If the ``strikethrough-rgba`` property has been set. .. attribute:: props.strikethrough_set :type: bool .. attribute:: props.style :type: ~gi.repository.Pango.Style Font style as a ``PangoStyle``, e.g. ``%PANGO_STYLE_ITALIC``. .. attribute:: props.style_set :type: bool .. attribute:: props.tabs :type: ~gi.repository.Pango.TabArray Custom tabs for this text. .. attribute:: props.tabs_set :type: bool .. attribute:: props.text_transform :type: ~gi.repository.Pango.TextTransform How to transform the text for display. .. versionadded:: 4.6 .. attribute:: props.text_transform_set :type: bool .. attribute:: props.underline :type: ~gi.repository.Pango.Underline Style of underline for this text. .. attribute:: props.underline_rgba :type: ~gi.repository.Gdk.RGBA This property modifies the color of underlines. If not set, underlines will use the foreground color. If :obj:`~gi.repository.Gtk.TextTag.props.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. .. attribute:: props.underline_rgba_set :type: bool If the ``underline-rgba`` property has been set. .. attribute:: props.underline_set :type: bool .. attribute:: props.variant :type: ~gi.repository.Pango.Variant Font variant as a ``PangoVariant``, e.g. ``%PANGO_VARIANT_SMALL_CAPS``. .. attribute:: props.variant_set :type: bool .. attribute:: props.weight :type: int Font weight as an integer. .. attribute:: props.weight_set :type: bool .. attribute:: props.word :type: bool Whether this tag represents a single word. This affects line breaks and cursor movement. .. versionadded:: 4.6 .. attribute:: props.word_set :type: bool .. attribute:: props.wrap_mode :type: ~gi.repository.Gtk.WrapMode Whether to wrap lines never, at word boundaries, or at character boundaries. .. attribute:: props.wrap_mode_set :type: bool Fields ------ .. rst-class:: interim-class .. class:: TextTag :no-index: .. attribute:: parent_instance .. attribute:: priv