File: class-gladexml.html

package info (click to toggle)
python-gtk2-doc 2.5.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,304 kB
  • ctags: 3,741
  • sloc: makefile: 38
file content (77 lines) | stat: -rw-r--r-- 21,837 bytes parent folder | download
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
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>gtk.glade.XML</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PyGTK 2.0 Reference Manual"><link rel="up" href="glade-class-reference.html" title="The gtk.glade Class Reference"><link rel="previous" href="glade-class-reference.html" title="The gtk.glade Class Reference"><link rel="next" href="pango-class-reference.html" title="The pango Class Reference"></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">gtk.glade.XML</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="glade-class-reference.html">Prev</a></td><th width="60%" align="center">The gtk.glade Class Reference</th><td width="20%" align="right"><a accesskey="n" href="pango-class-reference.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="class-gladexml"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2>gtk.glade.XML</h2><p>gtk.glade.XML &#8212; Allows dynamic loading of user interfaces
                from XML descriptions 
</p></div><div class="refsect1" lang="en"><a name="id3114773"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gtk.glade.XML</span></span>(<span class="ooclass"><span class="classname"><a href="class-gobject.html" title="gobject.GObject">gobject.GObject</a></span></span>):
<code class="constructorsynopsis">    <span class="methodname"><a href="class-gladexml.html#constructor-gladexml" title="Constructor">gtk.glade.XML</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>fname</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>root</tt></b></span><span class="initializer">=""</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>domain</tt></b></span><span class="initializer">=""</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>typedict</tt></b></span><span class="initializer">={}</span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gladexml.html#method-gladexml--signal-connect" title="gtk.glade.XML.signal_connect">signal_connect</a></span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>handler_name</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>func</tt></i></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gladexml.html#method-gladexml--signal-autoconnect" title="gtk.glade.XML.signal_autoconnect">signal_autoconnect</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>dict</tt></b></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gladexml.html#method-gladexml--get-widget" title="gtk.glade.XML.get_widget">get_widget</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>name</tt></b></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gladexml.html#method-gladexml--get-widget-prefix" title="gtk.glade.XML.get_widget_prefix">get_widget_prefix</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>name</tt></b></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gladexml.html#method-gladexml--relative-file" title="gtk.glade.XML.relative_file">relative_file</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>filename</tt></b></span></span>)</code><br></pre></td></tr></table><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
<span class="bold"><b>Functions</b></span>

<code class="methodsynopsis">    def <span class="methodname"><a href="class-gladexml.html#function-glade--xml-new-from-buffer" title="gtk.glade.xml_new_from_buffer">gtk.glade.xml_new_from_buffer</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>buffer</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>size</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>root</tt></b></span><span class="initializer">=""</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>domain</tt></b></span><span class="initializer">=""</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>typedict</tt></b></span><span class="initializer">={}</span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gladexml.html#function-glade--get-widget-name" title="gtk.glade.get_widget_name">gtk.glade.get_widget_name</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>widget</tt></b></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a href="class-gladexml.html#function-glade--get-widget-tree" title="gtk.glade.get_widget_tree">gtk.glade.get_widget_tree</a></span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>widget</tt></b></span></span>)</code></pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3031742"></a><h2>Ancestry</h2><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="synopsis">+-- <a href="class-gobject.html" title="gobject.GObject">gobject.GObject</a>
      +-- <a href="class-gladexml.html" title="gtk.glade.XML">gtk.glade.XML</a>
    </pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3086088"></a><h2>Description</h2><p>This object represents an `instantiation' of an XML interface
description.  When one of these objects is created, the XML file is read,
and the interface is created. The <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a> object
then provides an interface for accessing the widgets in the interface by the
names assigned to them inside the XML description.</p><p>The <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a> object
can also be used to connect handlers to the named signals in the
description.  Libglade also provides an interface by which it can look up
the signal handler names in the program's symbol table and automatically
connect as many handlers up as it can that way.</p></div><div class="refsect1" lang="en"><a name="constructor-gladexml"></a><h2>Constructor</h2><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="constructorsynopsis">    <span class="methodname">gtk.glade.XML</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>fname</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>root</tt></b></span><span class="initializer">=""</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>domain</tt></b></span><span class="initializer">=""</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>typedict</tt></b></span><span class="initializer">={}</span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>fname</tt></b>:</span></td><td>the XML file name</td></tr><tr><td><span class="term"><b class="parameter"><tt>root</tt></b>:</span></td><td>the widget node in <i class="parameter"><tt>fname</tt></i> to
start building from (or <tt class="literal">""</tt>)</td></tr><tr><td><span class="term"><b class="parameter"><tt>domain</tt></b>:</span></td><td>the translation domain for the XML file (or
<tt class="literal">""</tt> for default)</td></tr><tr><td><span class="term"><b class="parameter"><tt>typedict</tt></b>:</span></td><td>A dictionary used to lookup types (or
<tt class="literal">{}</tt> for default)</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>a new <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a>
object</td></tr></tbody></table><p>Creates a new <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a> object
(and the corresponding widgets) from the XML file specified by
<i class="parameter"><tt>fname</tt></i>. Optionally it will only build the interface
from the widget node specified by <i class="parameter"><tt>root</tt></i> (if it is not
<tt class="literal">""</tt>).  This feature is useful if you only want to build
say a toolbar or menu from the XML file, but not the window it is embedded
in. Note also that the XML parse tree is cached to speed up creating another
<a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a>
object for the same file.</p></div><div class="refsect1" lang="en"><a name="id2998484"></a><h2>Methods</h2><div class="refsect2" lang="en"><a name="method-gladexml--signal-connect"></a><h3>gtk.glade.XML.signal_connect</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">signal_connect</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>handler_name</tt></i></span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>func</tt></i></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><i class="parameter"><tt>handler_name</tt></i>:</span></td><td>the signal handler name</td></tr><tr><td><span class="term"><i class="parameter"><tt>func</tt></i>:</span></td><td>the signal handler function</td></tr></tbody></table><p>In the glade interface descriptions, signal handlers are
specified for widgets by name. The <tt class="methodname">signal_connect</tt>()
method allows you to connect a callback specified by
<i class="parameter"><tt>func</tt></i> to all signals in the <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a> file
with the signal handler name specified by
<i class="parameter"><tt>handler_name</tt></i>.</p></div><div class="refsect2" lang="en"><a name="method-gladexml--signal-autoconnect"></a><h3>gtk.glade.XML.signal_autoconnect</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">signal_connect</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>dict</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>dict</tt></b>:</span></td><td>a mapping or an instance</td></tr></tbody></table><p>The <tt class="methodname">signal_autoconnect</tt>() method is a
variation of the <a href="class-gladexml.html#method-gladexml--signal-connect" title="gtk.glade.XML.signal_connect">gtk.glade.XML.signal_connect</a>
method. It uses Python's introspective features to look at the keys (if
<i class="parameter"><tt>dict</tt></i> is a mapping) or attributes (if
<i class="parameter"><tt>dict</tt></i> is an instance) and tries to match them with the
signal handler names given in the interface description. The callbacks
referenced by each matched key or attribute are connected to their matching
signals. The argument is called <tt class="literal">dict</tt> due to compatibility
reasons since originally only the mapping interface was supported. The
instance variant was introduced in PyGTK 2.0.</p></div><div class="refsect2" lang="en"><a name="method-gladexml--get-widget"></a><h3>gtk.glade.XML.get_widget</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_widget</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>name</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>name</tt></b>:</span></td><td>the name of the widget</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the widget matching the name or
<tt class="literal">None</tt></td></tr></tbody></table><p>The <tt class="methodname">get_widget</tt>() method returns a
reference to the <a href="class-gtkwidget.html" title="gtk.Widget"><tt class="classname">gtk.Widget</tt></a> specified
by <i class="parameter"><tt>name</tt></i> in the interface
description. <tt class="literal">None</tt> is returned, if
<i class="parameter"><tt>name</tt></i> doesn't specify a widget in the
interface.</p></div><div class="refsect2" lang="en"><a name="method-gladexml--get-widget-prefix"></a><h3>gtk.glade.XML.get_widget_prefix</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_widget_prefix</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>name</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>name</tt></b>:</span></td><td>the prefix the widget names or
<tt class="literal">""</tt> for all widgets</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>A list of widgets that match <i class="parameter"><tt>name</tt></i>
as the start of their name or <tt class="literal">None</tt></td></tr></tbody></table><p>The <tt class="methodname">get_widget_prefix</tt>() method returns
a list of interface <a href="class-gtkwidget.html" title="gtk.Widget"><tt class="classname">gtk.Widget</tt></a> objects
that have names prefixed by
<i class="parameter"><tt>name</tt></i>. <tt class="literal">None</tt> is returned if no
interface widget names match the prefix <i class="parameter"><tt>name</tt></i>.</p></div><div class="refsect2" lang="en"><a name="method-gladexml--relative-file"></a><h3>gtk.glade.XML.relative_file</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">relative_file</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>filename</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>filename</tt></b>:</span></td><td>a relative file pathname</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the absolute file pathname</td></tr></tbody></table><p>The <tt class="methodname">relative_file</tt>() method resolves the
relative pathname specified by <i class="parameter"><tt>filename</tt></i>, using the
directory of the XML file as a base. If <i class="parameter"><tt>filename</tt></i>
contains an absolute pathname, then the original file name is
returned.</p></div></div><div class="refsect1" lang="en"><a name="id2934790"></a><h2>Functions</h2><div class="refsect2" lang="en"><a name="function-glade--xml-new-from-buffer"></a><h3>gtk.glade.xml_new_from_buffer</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">gtk.image_new_from_buffer</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>buffer</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>size</tt></b></span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>root</tt></b></span><span class="initializer">=""</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>domain</tt></b></span><span class="initializer">=""</span></span>, <span class="methodparam"><span class="parameter"><b class="parameter"><tt>typedict</tt></b></span><span class="initializer">={}</span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>buffer</tt></b>:</span></td><td>the string containing the XML buffer</td></tr><tr><td><span class="term"><b class="parameter"><tt>size</tt></b>:</span></td><td>size of the string</td></tr><tr><td><span class="term"><b class="parameter"><tt>root</tt></b>:</span></td><td>the widget node in fname to start building from
(or <tt class="literal">""</tt>)</td></tr><tr><td><span class="term"><b class="parameter"><tt>domain</tt></b>:</span></td><td>the translation domain for the XML file (or
<tt class="literal">""</tt> for default)</td></tr><tr><td><span class="term"><b class="parameter"><tt>typedict</tt></b>:</span></td><td>A dictionary used to lookup types (or
<tt class="literal">{}</tt> for default)</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>a new <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a>
 object.</td></tr></tbody></table><p>The <tt class="function">gtk.glade.xml_new_from_buffer</tt>()
function creates a new <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a> object
(and the corresponding widgets) from the string specified by
<i class="parameter"><tt>buffer</tt></i>. Optionally it will only build the interface
from the widget node specified by <i class="parameter"><tt>root</tt></i> (if it is not
<tt class="literal">""</tt>).  This feature is useful if you only want to build
say a toolbar or menu from the XML document, but not the window it is
embedded in.</p></div><div class="refsect2" lang="en"><a name="function-glade--get-widget-name"></a><h3>gtk.glade.get_widget_name</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">gtk.glade.get_widget_name</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>widget</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>widget</tt></b>:</span></td><td>a <a href="class-gtkwidget.html" title="gtk.Widget"><tt class="classname">gtk.Widget</tt></a></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the name of the widget</td></tr></tbody></table><p>The <tt class="function">gtk.glade.get_widget_name</tt>() function
returns the name of the <a href="class-gtkwidget.html" title="gtk.Widget"><tt class="classname">gtk.Widget</tt></a> specified
by <i class="parameter"><tt>widget</tt></i> that was generated by a <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a>
object.</p></div><div class="refsect2" lang="en"><a name="function-glade--get-widget-tree"></a><h3>gtk.glade.get_widget_tree</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">gtk.glade.get_widget_tree</span>(<span class="methodparam"><span class="parameter"><b class="parameter"><tt>widget</tt></b></span></span>)</code></pre></td></tr></table><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><span class="term"><b class="parameter"><tt>widget</tt></b>:</span></td><td>a <a href="class-gtkwidget.html" title="gtk.Widget"><tt class="classname">gtk.Widget</tt></a></td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a>
object that built <i class="parameter"><tt>widget</tt></i></td></tr></tbody></table><p>This <tt class="function">gtk.glade.get_widget_tree</tt>() function
is used to get the <a href="class-gladexml.html" title="gtk.glade.XML"><tt class="classname">gtk.glade.XML</tt></a> object
that built the <a href="class-gtkwidget.html" title="gtk.Widget"><tt class="classname">gtk.Widget</tt></a> specified
by <i class="parameter"><tt>widget</tt></i>.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="glade-class-reference.html">Prev</a></td><td width="20%" align="center"><a accesskey="u" href="glade-class-reference.html">Up</a></td><td width="40%" align="right"><a accesskey="n" href="pango-class-reference.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">The gtk.glade Class Reference</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">The pango Class Reference</td></tr></table></div></body></html>