gtk.TextTag
Prev | The gtk Class Reference | Next

## gtk.TextTag

gtk.TextTag — an object used to apply attributes to text in a `gtk.TextBuffer`

## Synopsis

    class gtk.TextTag(gobject.GObject):
        gtk.TextTag(name=None)
        def get_priority()
        def set_priority(priority)
        def event(event_object, event, iter)

## Ancestry

    +-- gobject.GObject
      +-- gtk.TextTag

## gtk.TextTag Properties

"accumulative-margin" | Read-Write | 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). Default value: `False` This property is available in GTK+ 2.12 and above.
"background" | Write | The background color as a string
"background-full-height" | Read-Write | If `True`, the background color fills the entire line height
"background-full-height-set" | Read-Write | If `True`, this tag affects background height
"background-gdk" | Read-Write | The background color as a (possibly unallocated) `gtk.gdk.Color`
"background-set" | Read-Write | If `True`, this tag affects the background color
"background-stipple" | Read-Write | The bitmap to use as a mask when drawing the text background
"background-stipple-set" | Read-Write | If `True`, this tag affects the background stipple
"direction" | Read-Write | The text direction: `gtk.TEXT_DIR_NONE`, `gtk.TEXT_DIR_LTR` or `gtk.TEXT_DIR_RTL`
"editable" | Read-Write | It `True` the text can be modified by the user
"editable-set" | Read-Write | If `True`, this tag affects text editability
"family" | Read-Write | The name of the font family, e.g. Sans, Helvetica, Times, Monospace
"family-set" | Read-Write | If `True`, this tag affects the font family
"font" | Read-Write | The font description as a string, e.g. "Sans Italic 12"
"font-desc" | Read-Write | The font description as a pango.FontDescription object
"foreground" | Write | The foreground color as a string
"foreground-gdk" | Read-Write | The foreground color as a (possibly unallocated) `gtk.gdk.Color`
"foreground-set" | Read-Write | If `True`, this tag affects the foreground color
"foreground-stipple" | Read-Write | The bitmap to use as a mask when drawing the text foreground
"foreground-stipple-set" | Read-Write | If `True`, this tag affects the foreground stipple
"indent" | Read-Write | The amount to indent the paragraph, in pixels
"indent-set" | Read-Write | If `True`, this tag affects indentation
"invisible" | Read-Write | If `True`, this text is hidden
"invisible-set" | Read-Write | If `True`, this tag affects text visibility
"justification" | Read-Write | The text justification: `gtk.JUSTIFY_LEFT`, `gtk.JUSTIFY_RIGHT`, `gtk.JUSTIFY_CENTER` or `gtk.JUSTIFY_FILL`
"justification-set" | Read-Write | If `True`, this tag affects paragraph justification
"language" | Read-Write | The language this text is in, as an ISO code. Pango can use this as a hint when rendering the text. If you don't understand this parameter, you probably don't need it.
"language-set" | Read-Write | If `True`, this tag affects the language the text is rendered as
"left-margin" | Read-Write | The width of the left margin in pixels
"left-margin-set" | Read-Write | If `True`, this tag affects the left margin
"name" | Read-Write | The name of the texttag or `None` if anonymous
"paragraph-background" | Write | The paragraph background color as a string. This property is available in GTK+ 2.8 and above.
"paragraph-background-gdk" | Read-Write | The paragraph background color as a as a (possibly unallocated) `gtk.gdk.Color`. This property is available in GTK+ 2.8 and above.
"paragraph-background-set" | Read-Write | if `True` this tag affects the paragraph background color
"pixels-above-lines" | Read-Write | The number of pixels of blank space above paragraphs
"pixels-above-lines-set" | Read-Write | If `True`, this tag affects the number of pixels above lines
"pixels-below-lines" | Read-Write | The number of pixels of blank space below paragraphs
"pixels-below-lines-set" | Read-Write | If `True`, this tag affects the number of pixels above lines
"pixels-inside-wrap" | Read-Write | The number of pixels of blank space between wrapped lines in a paragraph
"pixels-inside-wrap-set" | Read-Write | If `True`, this tag affects the number of pixels between wrapped lines
"right-margin" | Read-Write | The width of the right margin in pixels
"right-margin-set" | Read-Write | If `True`, this tag affects the right margin
"rise" | Read-Write | The offset of text above the baseline (below the baseline if rise is negative) in pixels
"rise-set" | Read-Write | If `True`, this tag affects the rise
"scale" | Read-Write | The 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_XX_SMALL`, `pango.SCALE_X_SMALL`, `pango.SCALE_SMALL`, `pango.SCALE_MEDIUM`, `pango.SCALE_LARGE`, `pango.SCALE_X_LARGE`, `pango.SCALE_XX_LARGE`.
"scale-set" | Read-Write | If `True`, this tag scales the font size by a factor
"size" | Read-Write | The font size in Pango units.
"size-points" | Read-Write | The font size in points
"size-set" | Read-Write | If `True`, this tag affects the font size
"stretch" | Read-Write | The font stretch - one of: `pango.STRETCH_ULTRA_CONDENSED`, `pango.STRETCH_EXTRA_CONDENSED`, `pango.STRETCH_CONDENSED`, `pango.STRETCH_SEMI_CONDENSED`, `pango.STRETCH_NORMAL`, `pango.STRETCH_SEMI_EXPANDED`, `pango.STRETCH_EXPANDED`, `pango.STRETCH_EXTRA_EXPANDED`, `pango.STRETCH_ULTRA_EXPANDED`
"stretch-set" | Read-Write | If `True`, this tag affects the font stretch
"strikethrough" | Read-Write | If `True`, strike through the text
"strikethrough-set" | Read-Write | If `True`, this tag affects strikethrough
"style" | Read-Write | The font style - one of: `pango.STYLE_NORMAL`, `pango.STYLE_OBLIQUE` or `pango.STYLE_ITALIC`.
"style-set" | Read-Write | If `True`, this tag affects the font style
"tabs" | Read-Write | The custom tabs for this text
"tabs-set" | Read-Write | If `True`, this tag affects tabs
"underline" | Read-Write | The style of underline for this text: `pango.UNDERLINE_NONE`, `pango.UNDERLINE_SINGLE`, `pango.UNDERLINE_DOUBLE` or `pango.UNDERLINE_LOW`
"underline-set" | Read-Write | If `True`, this tag affects underlining
"variant" | Read-Write | The font variant - either `pango.VARIANT_NORMAL` or `pango.VARIANT_SMALL_CAPS`.
"variant-set" | Read-Write | If `True`, this tag affects the font variant
"weight" | Read-Write | The font weight as an integer: `pango.WEIGHT_ULTRALIGHT` = 200, `pango.WEIGHT_LIGHT` = 300, `pango.WEIGHT_NORMAL` = 400, `pango.WEIGHT_BOLD` = 700, `pango.WEIGHT_ULTRABOLD` = 800, `pango.WEIGHT_HEAVY` = 900.
"weight-set" | Read-Write | If `True`, this tag affects the font weight
"wrap-mode" | Read-Write | The wrap mode of the text: `gtk.WRAP_NONE`, `gtk.WRAP_CHAR` or `gtk.WRAP_WORD`
"wrap-mode-set" | Read-Write | If `True`, this tag affects line wrap mode

## gtk.TextTag Signal Prototypes

gobject.GObject Signal Prototypes

"event" | `def callback(`texttag`, `widget`, `event`, `iter`, `user_param1`, `...`)`

## Description

A `gtk.TextTag` object holds attributes that can be applied to a range of text in a `gtk.TextBuffer`. A texttag can be associated with more than one `gtk.TextBuffer` by adding it to the `gtk.TextTagTable` objects of the textbuffers. The attributes of a texttag can be set using the `GObject.set_property`() method or as part of texttag creation using the `gtk.TextBuffer.create_tag`() method. Since not every attribute property of a `gtk.TextTag` may be set each attribute property has a boolean property that indicates whether the attribute property is set by this texttag. Therefore before retrieving an attribute value from a texttag you have to check if the associated boolean property of the attribute property is `True`.

## Constructor

        gtk.TextTag(name=None)

`name` : | tag name, or `None` if the texttag is anonymous
Returns : | a new `gtk.TextTag`

Creates a `gtk.TextTag` with the name specified by `name`. If `name` is `None` the texttag will be anonymous. The texttag attributes are configured using the `GObject.set_property`() method.

## Methods

### gtk.TextTag.get_priority

        def get_priority()

Returns : | the texttag's priority.

The get_priority() method returns the priority or the texttag.

### gtk.TextTag.set_priority

        def set_priority(priority)

`priority` : | the new priority

The `set_priority`() method sets the priority of a `gtk.TextTag` to the value specified by `priority`. Valid priorities start at 0 and go to one less than the value returned by the `gtk.TextTagTable.get_size`() method. Each texttag in a table has a unique priority; setting the priority of one texttag shifts the priorities of all the other texttags in the table to maintain a unique priority for each texttag. Higher priority tags "win" if two texttags both set the same text attribute for a range of text. When adding a texttag to a `gtk.TextTagTable`, it will be assigned the highest priority in the table by default; so normally the precedence of a set of texttags is the order in which they were added to the table, or created with the `gtk.TextBuffer.create_tag`() method, that adds the texttag to the buffer's table automatically.

### gtk.TextTag.event

        def event(event_object, event, iter)

`event_object` : | the object that received the event, such as a widget
`event` : | the event
`iter` : | the location where the event was received
Returns : | the result of signal emission (whether the event was handled)

The `event`() method emits the "event" signal on the `gtk.TextTag` for the widget specified by `event_object` with the event specified by `event` at the textbuffer location specified by `iter`. This method returns `True` if the event was handled.

## Signals

### The "event" gtk.TextTag Signal

        def callback(texttag, widget, event, iter, user_param1, ...)

`texttag` : | the texttag that received the signal
`widget` : | the widget that received `event`
`event` : | the event
`iter` : | the `gtk.TextIter` pointing to the location where the event was received
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "event" signal is emitted when an event occurs in a range of text that is enclosed in the `texttag`. The widget that the event occurred in is specified by `widget`. `iter` holds the location that the event occurred at and `event` describes the event.

Prev | Up | Next
gtk.TextMark | Home | gtk.TextTagTable