pango.AttrList

pango.AttrList — an object holding attributes that apply to a section of text

Synopsis

class pango.AttrList(gobject.GBoxed):
    pango.AttrList()
def copy()
def insert(attr)
def insert_before(attr)
def change(attr)
def splice(other, pos, len)
def get_iterator()
def filter(func, data=None)
Functions

    def pango.parse_markup(markup_text, accel_marker=u'\x00')

Description

The pango.AttrList object contains a list of attributes that apply to a section of text. The attributes are, in general, allowed to overlap in an arbitrary fashion, however, if the attributes are manipulated only through the change() method, the overlap between properties will meet stricter criteria. Since the pango.AttrList object is stored as a linear list, it is not suitable for storing attributes for large amounts of text. In general, you should not use a single pango.AttrList for more than one paragraph of text.

Constructor

    pango.AttrList()

Returns :

a new pango.AttrList object.

Creates a new pango.AttrList object.

Methods

pango.AttrList.copy

    def copy()

Returns :

a new pango.AttrList object

The copy() method returns a new pango.AttrList object that is a copy of the attribute list

pango.AttrList.insert

    def insert(attr)

attr :

the pango.Attribute to insert.

The insert() method inserts the pango.Attribute specified by attr into the attribute list. It will be inserted after all other attributes with a matching "start_index".

pango.AttrList.insert_before

    def insert_before(attr)

attr :

the pango.Attribute to insert.

The insert_before() method inserts the pango.Attribute specified by attr into the attribute list. It will be inserted before all other attributes with a matching "start_index".

pango.AttrList.change

    def change(attr)

attr :

the pango.Attribute to insert.

The change() method inserts the pango.Attribute specified by attr into the attribute list. It will replace any attributes of the same type on that segment and be merged with any adjoining attributes that are identical. This method is slower than the insert() method for creating an attribute list in order (potentially much slower for large lists). However, the insert() method is not suitable for continually changing a set of attributes since it never removes or combines existing attributes.

pango.AttrList.splice

    def splice(other, pos, len)

other :

another pango.AttrList

pos :

the position in this attribute list to insert other

len :

the length of the spliced segment. (Note that this must be specified since the attributes in other may only be present at some subsection of this range)

The splice() method splices the pango.AttrList specified by other into this attribute list. This method stretches each attribute with a range including the position specified by pos in the list by the amount specified by len, and then calls the change() method with a copy of each attribute in other in sequence (offset in position by pos).

pango.AttrList.get_iterator

    def get_iterator()

Returns :

a new pango.AttrIterator.

The get_iterator() method creates and returns a pango.AttrIterator initialized to the beginning of the attribute list.

pango.AttrList.filter

    def filter(func, data=None)

func :

a callback function that returns True if an attribute should be filtered out.

data :

data to be passed to func

Returns :

a new pango.AttrList or None.

Note

This method is available in PyGTK 2.4 and above.

The filter() method arranges for the callback function specified by function to be called on each pango.Attribute in the attribute list with the optional user data specified by data. The callback function signature is:

  def func(attribute, user_data)

where attribute is an attribute of the attribute list and user_data is data. The callback function returns True if the attribute should be filtered out of the attribute list. The filter method returns a new pango.AttrList containing the attributes that were filtered out (removed from) the attribute list.

Functions

pango.parse_markup

    def pango.parse_markup(markup_text, accel_marker=u'\x00')

markup_text :

a string containing the markup to parse.

accel_marker :

the Unicode character that precedes an accelerator, or u'\x00' for none

Returns :

a 3-tuple containing a pango.AttrList, the plain text in markup_text, and the first accelerator character in the text.

The parse_markup() function parses the text specified by markup_text and returns a 3-tuple containing a pango.AttrList, the plain text from markup_text and the first accelerator character that is preceded by the Unicode character specified by accel_marker. The returned accelerator character is a Unicode character that may be u'\x00' if there is no accelerator character.

See the The Pango Markup Language reference for more information.

The GError exception is raised if an error occurs while parsing the markup text.