gtk.TextTagTable
Prev | The gtk Class Reference | Next

## gtk.TextTagTable

gtk.TextTagTable — A collection of `gtk.TextTag` objects that can be used together

## Synopsis

    class gtk.TextTagTable(gobject.GObject):
        gtk.TextTagTable()
        def add(tag)
        def remove(tag)
        def lookup(name)
        def foreach(func, data=None)
        def get_size()

## Ancestry

    +-- gobject.GObject
      +-- gtk.TextTagTable

## gtk.TextTagTable Signal Prototypes

gobject.GObject Signal Prototypes

"tag-added" | `def callback(`texttagtable`, `texttag`, `user_param1`, `...`)`
"tag-changed" | `def callback(`texttagtable`, `texttag`, `size_changed`, `user_param1`, `...`)`
"tag-removed" | `def callback(`texttagtable`, `texttag`, `user_param1`, `...`)`

## Description

A `gtk.TextTagTable` object holds a set of `gtk.TextTag` objects for use with a `gtk.TextBuffer`. Usually a `gtk.TextTagTable` is created automatically when a `gtk.TextBuffer` is created but a standalone `gtk.TextTagTable` can be created using the gtk.TextTagTable() constructor. A `gtk.TextTagTable` can be passed as an argument to the gtk.TextBuffer() constructor to associate an existing `gtk.TextTagTable` rather than creating a new one. This is useful when several textbuffers need to use the same texttags.

## Constructor

        gtk.TextTagTable()

Returns : | a new `gtk.TextTagTable`

Creates a new `gtk.TextTagTable`. The table contains no tags by default.

## Methods

### gtk.TextTagTable.add

        def add(tag)

`tag` : | a `gtk.TextTag`

The `add`() method adds a texttag to the texttagtable. The texttag is assigned the highest priority in the texttagtable. A `ValueError` exception is raised if `tag` is in a texttag table already, or has the same name as another texttag in the texttagtable.

### gtk.TextTagTable.remove

        def remove(tag)

`tag` : | a `gtk.TextTag`

The `remove`() method removes a texttag from the texttagtable.

### gtk.TextTagTable.lookup

        def lookup(name)

`name` : | the name of a texttag
Returns : | The texttag, or `None` if none by that name is in the texttagtable.

The `lookup`() method looks in the texttagtable for a `gtk.TextTag` with the name specified by `name` and returns it if found. This method returns `None` if `name` does not identify a `gtk.TextTag` in the texttagtable.

### gtk.TextTagTable.foreach

        def foreach(func, data=None)

`func` : | a function to call on each texttag
`data` : | user data to pass to `func` or `None`

### Note

This method is available in PyGTK 2.4 and above.

The `foreach`() method calls the function specified by `func` on each texttag in the text tag table passing the user data specified by `data`. The signature of `func` is:

      def func(texttag, user_data):

where `texttag` is a `gtk.TextTag` in the text tag table and `user_data` is `data`.

### gtk.TextTagTable.get_size

        def get_size()

Returns : | the number of texttags in the texttagtable

The `get_size`() method returns the size of the texttagtable (number of texttags).

## Signals

### The "tag-added" gtk.TextTagTable Signal

        def callback(texttagtable, texttag, user_param1, ...)

`texttagtable` : | the texttagtable that received the signal
`texttag` : | a `gtk.TextTag`
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "tag-added" signal is emitted when the `gtk.TextTag` specified by `texttag` is added to `texttagtable`.

### The "tag-changed" gtk.TextTagTable Signal

        def callback(texttagtable, texttag, size_changed, user_param1, ...)

`texttagtable` : | the texttagtable that received the signal
`texttag` : | a `gtk.TextTag`
`size_changed` : | if `True` a `texttag` property has changed that may affect the size of the text enclosed by the texttag
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "tag-changed" signal is emitted when a property of the `gtk.TextTag` specified by `texttag` is changed. If `size_changed` is `True` the text enclosed by `texttag` will change size.

### The "tag-removed" gtk.TextTagTable Signal

        def callback(texttagtable, texttag, user_param1, ...)

`texttagtable` : | the texttagtable that received the signal
`texttag` : | a `gtk.TextTag`
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "tag-removed" signal is emitted when the `gtk.TextTag` specified by `texttag` is removed from `texttagtable`

Prev | Up | Next
gtk.TextTag | Home | gtk.TextView