/usr/share/doc/python-gtk2-tutorial/html/sec-TextBuffers.html is in python-gtk2-tutorial 2.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>13.3. Text Buffers</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PyGTK 2.0 Tutorial"><link rel="up" href="ch-TextViewWidget.html" title="Chapter 13. TextView Widget"><link rel="previous" href="sec-TextViews.html" title="13.2. TextViews"><link rel="next" href="sec-TextIters.html" title="13.4. Text Iters"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">13.3. Text Buffers</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-TextViews.html">Prev</a> </td><th width="60%" align="center">Chapter 13. TextView Widget</th><td width="20%" align="right"> <a accesskey="n" href="sec-TextIters.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-TextBuffers"></a>13.3. Text Buffers</h2></div></div><div></div></div><p>A <tt class="classname">TextBuffer</tt> is the core component of the
PyGTK text editing system. It contains the text, the
<tt class="classname">TextTag</tt>s in a <tt class="classname">TextTagTable</tt> and
the <tt class="classname">TextMark</tt>s which together describe how the text is
to be displayed and allow a user to interactively modify the text and text
display. As noted in the previous section a
<tt class="classname">TextBuffer</tt> is associated with one or more
<tt class="classname">TextView</tt>s which display the
<tt class="classname">TextBuffer</tt> contents.</p><p>A <tt class="classname">TextBuffer</tt> can be created automatically
when a <tt class="classname">TextView</tt> is created or it can be created with
the function:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer = TextBuffer(<b class="parameter"><tt>table</tt></b>=None)
</pre></td></tr></table><p>where <i class="parameter"><tt>table</tt></i> is a
<tt class="classname">TextTagTable</tt>. If <i class="parameter"><tt>table</tt></i> is not
specified (or is <tt class="literal">None</tt>) a
<tt class="classname">TextTagTable</tt> will be created for the
<tt class="classname">TextBuffer</tt>.</p><p>There are a large number of methods that can be used to:</p><div class="itemizedlist"><ul type="disc"><li>insert and remove text from a buffer</li><li>create, delete and manipulate marks</li><li>manipulate the cursor and the selection</li><li>create, apply and remove tags</li><li>specify and manipulate
<tt class="classname">TextIter</tt>s</li><li>get status information</li></ul></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id3108401"></a>13.3.1. TextBuffer Status Information</h3></div></div><div></div></div><p>You can retrieve the number of lines in a
<i class="parameter"><tt>textbuffer</tt></i> by using the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
line_count = textbuffer.get_line_count()
</pre></td></tr></table><p>Likewise you can get the number of characters in the
<i class="parameter"><tt>textbuffer</tt></i> using:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
char_count = textbuffer.get_char_count()
</pre></td></tr></table><p>When the <i class="parameter"><tt>textbuffer</tt></i> contents are changed
the modified flag in the textbuffer is set. The status of the modified flag
can be retrieved using the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
modified = textbuffer.get_modified()
</pre></td></tr></table><p>If the program saves the contents of the textbuffer the
following method can be used to reset the modified flag:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.set_modified(<b class="parameter"><tt>setting</tt></b>)
</pre></td></tr></table></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id3108455"></a>13.3.2. Creating TextIters</h3></div></div><div></div></div><p>A <tt class="classname">TextIter</tt> is used to specify a location
within a <tt class="classname">TextBuffer</tt> between two
characters. <tt class="classname">TextBuffer</tt> methods that manipulate text
use <tt class="classname">TextIter</tt>s to specify where the method is to be
applied. <tt class="classname">TextIter</tt>s have a large number of methods
that will be described in the ><tt class="classname">TextIter</tt>s
section.</p><p>The basic <tt class="classname">TextBuffer</tt> methods used to
create <tt class="classname">TextIter</tt>s
are:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
iter = textbuffer.get_iter_at_offset(<b class="parameter"><tt>char_offset</tt></b>)
iter = textbuffer_get_iter_at_line(<b class="parameter"><tt>line_number</tt></b>)
iter = textbuffer.get_iter_at_line_offset(<b class="parameter"><tt>line_number</tt></b>, <b class="parameter"><tt>line_offset</tt></b>)
iter = textbuffer.get_iter_at_mark(<b class="parameter"><tt>mark</tt></b>)
</pre></td></tr></table><p><tt class="methodname">get_iter_at_offset</tt>() creates an iter
that is just after <i class="parameter"><tt>char_offset</tt></i> chars from the start
of the textbuffer.</p><p><tt class="methodname">get_iter_at_line</tt>() creates an iter that
is just before the first character in
<i class="parameter"><tt>line_number</tt></i>.</p><p><tt class="methodname">get_iter_at_line_offset</tt>() creates an
iter that is just after the <i class="parameter"><tt>line_offset</tt></i> character in
<i class="parameter"><tt>line_number</tt></i>.</p><p><tt class="methodname">get_iter_at_mark</tt>() creates an iter that
is at the same position as the given <i class="parameter"><tt>mark</tt></i>.</p><p>The following methods create one or more
<tt class="classname">TextIter</tt>s at specific buffer locations:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
startiter = textbuffer.get_start_iter()
enditer = textbuffer_get_end_iter()
startiter, enditer = textbuffer.get_bounds()
start, end = textbuffer.get_selection_bounds()
</pre></td></tr></table><p><tt class="methodname">get_start_iter</tt>() creates an iter that
is just before the first character in the textbuffer.</p><p><tt class="methodname">get_end_iter</tt>() creates an iter that is
just after the last character in the textbuffer.</p><p><tt class="methodname">get_bounds</tt>() creates a tuple of two
iters that are just before the first character and just after the last
character in the textbuffer respectively.</p><p><tt class="methodname">get_selection_bounds</tt>() creates a tuple
of two iters that have the same location as the
<i class="parameter"><tt>insert</tt></i> and <i class="parameter"><tt>selection_bound</tt></i>
marks in the textbuffer.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id3121630"></a>13.3.3. Text Insertion, Retrieval and Deletion</h3></div></div><div></div></div><p>The text in a <tt class="classname">TextBuffer</tt> can be set
using the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.set_text(<b class="parameter"><tt>text</tt></b>)
</pre></td></tr></table><p>This method replaces the current contents of textbuffer with
<i class="parameter"><tt>text</tt></i>.</p><p>The most general method to insert characters in a textbuffer
is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.insert(<b class="parameter"><tt>iter</tt></b>, <b class="parameter"><tt>text</tt></b>)
</pre></td></tr></table><p>which inserts <i class="parameter"><tt>text</tt></i> at the textbuffer
location specified by <i class="parameter"><tt>iter</tt></i>.</p><p>If you want to simulate the insertion of text by an
interactive user use the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
result = textbuffer.insert_interactive(<b class="parameter"><tt>iter</tt></b>, <b class="parameter"><tt>text</tt></b>, <b class="parameter"><tt>default_editable</tt></b>)
</pre></td></tr></table><p>which inserts <i class="parameter"><tt>text</tt></i> in the textbuffer at
the location specified by <i class="parameter"><tt>iter</tt></i> but only if the
location is editable (i.e. does not have a tag that specifies the text is
non-editable) and the <i class="parameter"><tt>default_editable</tt></i> value is
<tt class="literal">TRUE</tt>. The result indicates whether the text was
inserted.</p><p><i class="parameter"><tt>default_editable</tt></i> indicates the
editability of text that doesn't have a tag affecting editability;
<i class="parameter"><tt>default_editable</tt></i> is usually determined by a call to
the <tt class="classname">TextView</tt> <tt class="methodname">get_editable</tt>()
method.</p><p>Other methods that insert text are:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.insert_at_cursor(<b class="parameter"><tt>text</tt></b>)
result = textbuffer.insert_at_cursor_interactive(<b class="parameter"><tt>text</tt></b>, <b class="parameter"><tt>default_editable</tt></b>)
textbuffer.insert_range(<b class="parameter"><tt>iter</tt></b>, <b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>)
result = textbuffer.insert_range_interactive(<b class="parameter"><tt>iter</tt></b>, <b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>, <b class="parameter"><tt>default_editable</tt></b>)
</pre></td></tr></table><p><tt class="methodname">insert_at_cursor</tt>() is a convenience
method that inserts text at the current cursor
(<i class="parameter"><tt>insert</tt></i>) location.</p><p><tt class="methodname">insert_range</tt>() copies text, pixbufs and
tags between <i class="parameter"><tt>start</tt></i> and <i class="parameter"><tt>end</tt></i>
from a <tt class="classname">TextBuffer</tt> (if different from textbuffer the
tag table must be the same) and inserts the copy into textbuffer at
<i class="parameter"><tt>iter</tt></i>'s location.</p><p>The interactive versions of these methods operate the same way
except they will only insert if the location is editable.</p><p>Finally, text can be inserted and have tags applied at the
same time using the methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.insert_with_tags(iter, text, tag1, tag2, ...)
textbuffer.insert_with_tags_by_name(iter, text, tagname1, tagname2, ...)
</pre></td></tr></table><p><tt class="methodname">insert_with_tags</tt>() inserts the
<i class="parameter"><tt>text</tt></i> in the textbuffer at the location specified by
<i class="parameter"><tt>iter</tt></i> and applies the given tags.</p><p><tt class="methodname">insert_with_tags_by_name</tt>() does that
same thing but allows you to specify the tags using the tag name.</p><p>The text in a textbuffer can be deleted by using the
methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.delete(<b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>)
result = textbuffer.delete_interactive(<b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>, <b class="parameter"><tt>default_editable</tt></b>)
</pre></td></tr></table><p><tt class="methodname">delete</tt>() removes the text between the
<i class="parameter"><tt>start</tt></i> and <i class="parameter"><tt>end</tt></i>
<tt class="classname">TextIter</tt> locations in textbuffer.</p><p><tt class="methodname">delete_interactive</tt>() removes all the
editable (as determined by the applicable text tags and the
<i class="parameter"><tt>default_editable</tt></i> argument) text between
<i class="parameter"><tt>start</tt></i> and <i class="parameter"><tt>end</tt></i>.</p><p>You can retrieve a copy of the text from a textbuffer by using
the methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
text = textbuffer.get_text(<b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>, <b class="parameter"><tt>include_hidden_chars</tt></b>=TRUE)
text = textbuffer.get_slice(<b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>, <b class="parameter"><tt>include_hidden_chars</tt></b>=TRUE)
</pre></td></tr></table><p><tt class="methodname">get_text</tt>() returns a copy of the
<i class="parameter"><tt>text</tt></i> in textbuffer between
<i class="parameter"><tt>start</tt></i> and <i class="parameter"><tt>end</tt></i>; undisplayed
text is excluded if <i class="parameter"><tt>include_hidden_chars</tt></i> is
<tt class="literal">FALSE</tt>. Characters which represent embedded images or
widgets are excluded.</p><p><tt class="methodname">get_slice</tt>() is the same as
<tt class="methodname">get_text</tt>() except that the returned
<i class="parameter"><tt>text</tt></i> includes a 0xFFFC character for each embedded
image or widget.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id3122000"></a>13.3.4. TextMarks</h3></div></div><div></div></div><p><tt class="classname">TextMark</tt>s are similar to
<tt class="classname">TextIter</tt>s in that they specify a location in a
<tt class="classname">TextBuffer</tt> between two characters. However,
<tt class="classname">TextMark</tt>s maintain their location information across
buffer modifications. The <tt class="classname">TextMark</tt> methods will be
described in the <tt class="classname">TextMark</tt>s section.</p><p>A textbuffer contains two built-in marks: the
<i class="parameter"><tt>insert</tt></i> (cursor) mark and the
<i class="parameter"><tt>selection_bound</tt></i> mark. The
<i class="parameter"><tt>insert</tt></i> mark is the default location for the insertion
of text and the <i class="parameter"><tt>selection_bound</tt></i> mark combines with
the <i class="parameter"><tt>insert</tt></i> mark to define a selection range.</p><p>The built-in marks can be retrieved by using the
methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
insertmark = textbuffer.get_insert()
selection_boundmark = textbuffer.get_selection_bound()
</pre></td></tr></table><p>The <i class="parameter"><tt>insert</tt></i> and
<i class="parameter"><tt>selection_bound</tt></i> marks can be placed simultaneously at
a location by using the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.place_cursor(<b class="parameter"><tt>where</tt></b>)
</pre></td></tr></table><p><i class="parameter"><tt>where</tt></i> is a textiter specifying the
location. The <tt class="methodname">place_cursor</tt>() method is needed to
avoid temporarily creating a selection if the marks were moved
individually.</p><p><tt class="classname">TextMark</tt>s are created by using the
method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
mark = textbuffer.create_mark(<b class="parameter"><tt>mark_name</tt></b>, <b class="parameter"><tt>where</tt></b>, <b class="parameter"><tt>left_gravity</tt></b>=FALSE)
</pre></td></tr></table><p>where <i class="parameter"><tt>mark_name</tt></i> is the name assigned to
the created mark (can be <tt class="literal">None</tt> to create an anonymous mark),
<i class="parameter"><tt>where</tt></i> is the textiter specifying the location of the
mark in textbuffer and <i class="parameter"><tt>left_gravity</tt></i> indicates where
the mark will be located after text is inserted at the mark (left if
<tt class="literal">TRUE</tt> or right if <tt class="literal">FALSE</tt>).</p><p>A mark can be moved in the textbuffer by using the
methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.move_mark(<b class="parameter"><tt>mark</tt></b>, <b class="parameter"><tt>where</tt></b>)
textbuffer.move_mark_by_name(<b class="parameter"><tt>name</tt></b>, <b class="parameter"><tt>where</tt></b>)
</pre></td></tr></table><p><i class="parameter"><tt>mark</tt></i> specifies the mark to be moved.
<i class="parameter"><tt>name</tt></i> specifies the name of the mark to be moved.
<i class="parameter"><tt>where</tt></i> is a textiter specifying the new
location.</p><p>A mark can be deleted from a textbuffer by using the
methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.delete_mark(<b class="parameter"><tt>mark</tt></b>)
textbuffer.delete_mark_by_name(<b class="parameter"><tt>name</tt></b>)
</pre></td></tr></table><p>A mark can be retrieved by name using the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
mark = textbuffer.get_mark(<b class="parameter"><tt>name</tt></b>)
</pre></td></tr></table></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id3122216"></a>13.3.5. Creating and Applying TextTags</h3></div></div><div></div></div><p><tt class="classname">TextTag</tt>s contain one or more attributes
(e.g. foreground and background colors, font, editability) that can be
applied to one or more ranges of text in a
<tt class="classname">TextBuffer</tt>. The attributes that can be specified by
<tt class="classname">TextTag</tt> properties will be described in <a href="sec-TextTagsAndTextTagTables.html#sec-TextTags" title="13.6.1. Text Tags">Section 13.6.1, “Text Tags”</a>.</p><p>A <tt class="classname">TextTag</tt> can be created with attributes
and installed in the <tt class="classname">TextTagTable</tt> of a
<tt class="classname">TextBuffer</tt> by using the convenience method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
tag = textbuffer.create_tag(name=None, attr1=val1, attr2=val2, ...)
</pre></td></tr></table><p>where <i class="parameter"><tt>name</tt></i> is a string specifying the
name of the tag or <tt class="literal">None</tt> if the tag is an anonymous tag
and the keyword-value pairs specify the attributes that the tag will
have. See the <tt class="classname">TextTag</tt>> section for information on
what attributes can be set by the <tt class="classname">TextTag</tt>
properties.</p><p>A tag can be applied to a range of text in a textbuffer by
using the methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.apply_tag(<b class="parameter"><tt>tag</tt></b>, <b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>)
textbuffer.apply_tag_by_name(<b class="parameter"><tt>name</tt></b>, <b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>)
</pre></td></tr></table><p><i class="parameter"><tt>tag</tt></i> is the tag to be applied to the text.
<i class="parameter"><tt>name</tt></i> is the name of the tag to be applied.
<i class="parameter"><tt>start</tt></i> and <i class="parameter"><tt>end</tt></i> are textiters
that specify the range of text that the <i class="parameter"><tt>tag</tt></i> is to be
applied to.</p><p>A tag can be removed from a range of text by using the
methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.remove_tag(<b class="parameter"><tt>tag</tt></b>, <b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>)
textbuffer.remove_tag_by_name(<b class="parameter"><tt>name</tt></b>, <b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>)
</pre></td></tr></table><p>All tags for a range of text can be removed by using the
method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.remove_all_tags(<b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>)
</pre></td></tr></table></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id3122398"></a>13.3.6. Inserting Images and Widgets</h3></div></div><div></div></div><p>In addition to text a <tt class="classname">TextBuffer</tt> can
contain pixbuf images and an anchor location for widgets. A widget can be
added to a <tt class="classname">TextView</tt> at an anchor location. A
different widget can be added in each <tt class="classname">TextView</tt> which
displays a buffer with an anchor.</p><p>A pixbuf can be inserted by using the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
textbuffer.insert_pixbuf(<b class="parameter"><tt>iter</tt></b>, <b class="parameter"><tt>pixbuf</tt></b>)
</pre></td></tr></table><p>where <i class="parameter"><tt>iter</tt></i> specifies the location in the
<i class="parameter"><tt>textbuffer</tt></i> to insert the
<i class="parameter"><tt>pixbuf</tt></i>. The image will be counted as one character
and will be represented in a <tt class="methodname">get_slice</tt>() return
(but left out of a <tt class="methodname">get_text</tt>() return) as the
Unicode character "0xFFFC".</p><p>A GTK+ widget can be inserted in a
<tt class="classname">TextView</tt> at a buffer location specified with a
<tt class="classname">TextChildAnchor</tt>. The
<tt class="classname">TextChildAnchor</tt> will be counted as one character and
represented as "0xFFFC" similar to a pixbuf.</p><p>The <tt class="classname">TextChildAnchor</tt> can be created and
inserted in the buffer by using the convenience method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
anchor = text_buffer.create_child_anchor(<b class="parameter"><tt>iter</tt></b>)
</pre></td></tr></table><p>where <i class="parameter"><tt>iter</tt></i> is the location for the
child_anchor.</p><p>A <tt class="classname">TextChildAnchor</tt> can also be created
and inserted in two operations as:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
anchor = gtk.TextChildAnchor()
text_buffer.insert_child_anchor(<b class="parameter"><tt>iter</tt></b>, <b class="parameter"><tt>anchor</tt></b>)
</pre></td></tr></table><p>Then the widget can be added to the
<tt class="classname">TextView</tt> at an anchor location using the
method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
text_view.add_child_at_anchor(<b class="parameter"><tt>child</tt></b>, <b class="parameter"><tt>anchor</tt></b>)
</pre></td></tr></table><p>The list of widgets at a particular buffer anchor can be
retrieved using the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
widget_list = anchor.get_widgets()
</pre></td></tr></table><p>A widget can also be added to a <tt class="classname">TextView</tt>
using the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
text_view.add_child_in_window(<b class="parameter"><tt>child</tt></b>, <b class="parameter"><tt>which_window</tt></b>, <b class="parameter"><tt>xpos</tt></b>, <b class="parameter"><tt>ypos</tt></b>)
</pre></td></tr></table><p>where the <i class="parameter"><tt>child</tt></i> widget is placed in
<i class="parameter"><tt>which_window</tt></i> at the location specified by
<i class="parameter"><tt>xpos</tt></i> and <i class="parameter"><tt>ypos</tt></i>.
<i class="parameter"><tt>which_window</tt></i> indicates in which of the windows that
make up the <tt class="classname">TextView</tt> the widget is to be
placed:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
gtk.TEXT_WINDOW_TOP
gtk.TEXT_WINDOW_BOTTOM
gtk.TEXT_WINDOW_LEFT
gtk.TEXT_WINDOW_RIGHT
gtk.TEXT_WINDOW_TEXT
gtk.TEXT_WINDOW_WIDGET
</pre></td></tr></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-TextViews.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch-TextViewWidget.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-TextIters.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">13.2. TextViews </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 13.4. Text Iters</td></tr></table></div></body></html>
|