Imported Upstream version 2.28.4
[platform/upstream/pygobject2.git] / docs / html / class-gobject.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>gobject.GObject</title><link rel="stylesheet" type="text/css" href="style.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="PyGObject Reference Manual"><link rel="up" href="gobject-class-reference.html" title="PyGObject Class Reference"><link rel="prev" href="gobject-class-reference.html" title="PyGObject Class Reference"><link rel="next" href="class-gobjectgboxed.html" title="gobject.GBoxed"></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">gobject.GObject</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="gobject-class-reference.html">Prev</a> </td><th width="60%" align="center">PyGObject Class Reference</th><td width="20%" align="right"> <a accesskey="n" href="class-gobjectgboxed.html">Next</a></td></tr></table><hr></div><div class="refentry" title="gobject.GObject"><a name="class-gobject"></a><div class="titlepage"></div><div class="refnamediv"><h2><span class="refentrytitle">gobject.GObject</span></h2><p>gobject.GObject — the base class</p></div><div class="refsect1" title="Synopsis"><a name="id658986"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gobject.GObject</span></span>:
2 <code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--get-property" title="gobject.GObject.get_property">get_property</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>property_name</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--get-properties" title="gobject.GObject.get_properties">get_properties</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>first_property_name</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--set-property" title="gobject.GObject.set_property">set_property</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>property_name</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>value</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--set-properties" title="gobject.GObject.set_properties">set_properties</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>property_name</code></em></span><span class="initializer">=value</span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--freeze-notify" title="gobject.GObject.freeze_notify">freeze_notify</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--notify" title="gobject.GObject.notify">notify</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>property_name</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--thaw-notify" title="gobject.GObject.thaw_notify">thaw_notify</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--get-data" title="gobject.GObject.get_data">get_data</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>key</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--set-data" title="gobject.GObject.set_data">set_data</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>key</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>data</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--connect" title="gobject.GObject.connect">connect</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>handler</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--connect-after" title="gobject.GObject.connect_after">connect_after</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>handler</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--connect-object" title="gobject.GObject.connect_object">connect_object</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>handler</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--connect-object-after" title="gobject.GObject.connect_object_after">connect_object_after</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>handler</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--disconnect" title="gobject.GObject.disconnect">disconnect</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--handler-disconnect" title="gobject.GObject.handler_disconnect">handler_disconnect</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--handler-is-connected" title="gobject.GObject.handler_is_connected">handler_is_connected</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--handler-block" title="gobject.GObject.handler_block">handler_block</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--handler-unblock" title="gobject.GObject.handler_unblock">handler_unblock</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--handler-block-by-func" title="gobject.GObject.handler_block_by_func">handler_block_by_func</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>callable</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--handler-unblock-by-func" title="gobject.GObject.handler_unblock_by_func">handler_unblock_by_func</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>callable</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--emit" title="gobject.GObject.emit">emit</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--stop-emission" title="gobject.GObject.stop_emission">stop_emission</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--emit-stop-by-name" title="gobject.GObject.emit_stop_by_name">emit_stop_by_name</a></span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>)</code><br><code class="methodsynopsis">    def <span class="methodname"><a class="link" href="class-gobject.html#method-gobject--chain" title="gobject.GObject.chain">chain</a></span>(<span class="methodparam"></span>)</code><br></pre></td></tr></table></div><div class="refsect1" title="Ancestry"><a name="id642496"></a><h2>Ancestry</h2><pre class="synopsis">+-- <a class="link" href="class-gobject.html" title="gobject.GObject">gobject.GObject</a>
3 </pre></div><div class="refsect1" title="Attributes"><a name="id642482"></a><h2>Attributes</h2><div class="blockquote"><table width="100%" border="0" bgcolor="#E0E0E0"><tr><td valign="top"><div class="informaltable"><table cellpadding="5" width="100%" border="0"><colgroup><col width="1in"><col width="1in"><col width="4in"></colgroup><tbody><tr valign="top"><td valign="top">"props"</td><td valign="top">Read/Write</td><td valign="top">
4               <p>This attribute gives full access to GObject properties as
5                   simple attributes. It can be used to iterate over all the object
6                   properties, and can be used both on class or instance objects.</p>
7               <p>Examples:</p>
8               <pre class="programlisting">
9 button = Button()
10 button_label = button.props.label
11 button.props.label = 'Click on this fancy button'
12 for pspec in button.props:
13     print pspec
14     print button.get_property(pspec.name)
15 label_pspec = Button.props.label
16 button_label = button.get_property(label_pspec.name)
17               </pre>
18             </td></tr><tr valign="top"><td valign="top">"__doc__"</td><td valign="top">Read</td><td valign="top">The documentation for the object type. Uses
19               "__gdoc__" if no specific documentation set.</td></tr><tr valign="top"><td valign="top">"__gdoc__"</td><td valign="top">Read</td><td valign="top">The generated documentation for the underlying GObject
20               type.</td></tr><tr valign="top"><td valign="top">"__gtype__"</td><td valign="top">Read</td><td valign="top">The underlying GObject type.</td></tr><tr valign="top"><td valign="top">"__grefcount__"</td><td valign="top">Read</td><td valign="top">The reference count for the underlying GObject.</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" title="gobject.GObject Signal Prototypes"><a name="signal-prototypes-gobject"></a><h2>gobject.GObject Signal Prototypes</h2><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term">"<a class="link" href="class-gobject.html#signal-gobject--notify" title='The GObject "notify" Signal'>notify</a>"</span></p></td><td><code class="methodsynopsis">    def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>gobject</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>property_spec</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr></tbody></table></div><div class="refsect1" title="Description"><a name="id647704"></a><h2>Description</h2><p>The <a class="link" href="class-gobject.html" title="gobject.GObject"><code class="classname">gobject.GObject</code></a>
21     class is the base class providing the common attributes and methods for
22     the PyGTK classes. The <a class="link" href="class-gobject.html" title="gobject.GObject"><code class="classname">gobject.GObject</code></a>
23     class is not a user interface widget class.</p><p>The <a class="link" href="class-gobject.html" title="gobject.GObject"><code class="classname">gobject.GObject</code></a>
24     class provides the signal management methods, the object property access
25     methods and the object data management methods.</p></div><div class="refsect1" title="Methods"><a name="id647671"></a><h2>Methods</h2><div class="refsect2" title="gobject.GObject.get_property"><a name="method-gobject--get-property"></a><h3>gobject.GObject.get_property</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_property</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>property_name</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>property_name</code></em> :</span></p></td><td>a string containing the property name for the
26 GObject</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a Python object containing the value of the
27 property</td></tr></tbody></table><p>The <code class="methodname">get_property</code>() method returns the
28 value of the property specified by <em class="parameter"><code>property_name</code></em> or
29 None if there is no value associated with the property.</p><p>The <code class="exceptionname">TypeError</code> exception is raised
30 if the property name is not registered with the object class.</p></div><div class="refsect2" title="gobject.GObject.get_properties"><a name="method-gobject--get-properties"></a><h3>gobject.GObject.get_properties</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_properties</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>first_property_name</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>first_property_name</code></em> :</span></p></td><td>a string containing the first property name for the
31 GObject</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional property names 
32 </td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a tuple containing the property values 
33 requested</td></tr></tbody></table><p>The <code class="methodname">get_properties</code>() method returns a tuple containing
34 the values of the properties requested, or
35 None if there is no value associated with the property.</p><p>The <code class="exceptionname">TypeError</code> exception is raised
36 if the property name is not registered with the object class.</p></div><div class="refsect2" title="gobject.GObject.set_property"><a name="method-gobject--set-property"></a><h3>gobject.GObject.set_property</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">set_property</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>property_name</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>value</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>property_name</code></em> :</span></p></td><td>a string containing the property
37 name</td></tr><tr><td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td><td>a Python object containing the property value
38 to be set</td></tr></tbody></table><p>The <code class="methodname">set_property</code>() method sets the
39 property specified by <em class="parameter"><code>property_name</code></em> to the specified
40 <em class="parameter"><code>value</code></em>.</p><p>The <code class="exceptionname">TypeError</code> exception is raised
41 if the property name is not registered with the object class or if the value
42 specified could not be converted to the property type.</p></div><div class="refsect2" title="gobject.GObject.set_properties"><a name="method-gobject--set-properties"></a><h3>gobject.GObject.set_properties</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">set_properties</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>property_name</code></em></span><span class="initializer">=value</span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>property_name</code></em> :</span></p></td><td>the property name</td></tr><tr><td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td><td>a Python object containing the property value
43 to be set</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional property name and value 
44 kwargs</td></tr></tbody></table><p>The <code class="methodname">set_properties</code>() method sets the
45 property specified by <em class="parameter"><code>property_name</code></em> to the specified
46 <em class="parameter"><code>value</code></em>, followed by pairs of property name 
47 and value as keyword arguments.</p><p>The <code class="exceptionname">TypeError</code> exception is raised
48 if the property name is not registered with the object class or if the value
49 specified could not be converted to the property type.</p></div><div class="refsect2" title="gobject.GObject.freeze_notify"><a name="method-gobject--freeze-notify"></a><h3>gobject.GObject.freeze_notify</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">freeze_notify</span>(<span class="methodparam"></span>)</code></pre><p>The <code class="methodname">freeze_notify</code>() method freezes the
50 object's property-changed notification queue so that "notify" signals are
51 blocked until the <code class="methodname">thaw_notify</code>() method is
52 called.</p></div><div class="refsect2" title="gobject.GObject.notify"><a name="method-gobject--notify"></a><h3>gobject.GObject.notify</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">notify</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>property_name</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>property_name</code></em> :</span></p></td><td>a string containing a property
53 name</td></tr></tbody></table><p>The <code class="methodname">notify</code>() method causes the "notify"
54 signal for the property specified by <em class="parameter"><code>property_name</code></em> to
55 be emitted.</p></div><div class="refsect2" title="gobject.GObject.thaw_notify"><a name="method-gobject--thaw-notify"></a><h3>gobject.GObject.thaw_notify</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">thaw_notify</span>(<span class="methodparam"></span>)</code></pre><p>The <code class="methodname">thaw_notify</code>() method thaws the
56 object's property-changed notification queue so that "notify" signals are
57 emitted.</p></div><div class="refsect2" title="gobject.GObject.get_data"><a name="method-gobject--get-data"></a><h3>gobject.GObject.get_data</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">get_data</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>key</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td><td>a string used as the key</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a Python object containing the associated
58 data</td></tr></tbody></table><p>The <code class="methodname">get_data</code>() method returns the
59 Python object associated with the specified <em class="parameter"><code>key</code></em> or
60 None if there is no data associated with the <em class="parameter"><code>key</code></em> or
61 if there is no key associated with the object.</p></div><div class="refsect2" title="gobject.GObject.set_data"><a name="method-gobject--set-data"></a><h3>gobject.GObject.set_data</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">set_data</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>key</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>data</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td><td>a string used as a key</td></tr><tr><td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td><td>a Python object that is the value to be
62 associated with the key</td></tr></tbody></table><p>The <code class="methodname">set_data</code>() method associates the
63 specified Python object (<em class="parameter"><code>data</code></em>) with
64 <em class="parameter"><code>key</code></em>.</p></div><div class="refsect2" title="gobject.GObject.connect"><a name="method-gobject--connect"></a><h3>gobject.GObject.connect</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">connect</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>handler</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>detailed_signal</code></em> :</span></p></td><td>a string containing the signal
65 name</td></tr><tr><td><p><span class="term"><em class="parameter"><code>handler</code></em> :</span></p></td><td>a Python function or method
66 object.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional optional
67 parameters</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>an integer identifier</td></tr></tbody></table><p>The <code class="methodname">connect</code>() method adds a function or
68 method (<em class="parameter"><code>handler</code></em>)to the end of the list of signal
69 handlers for the named <em class="parameter"><code>detailed_signal</code></em> but before the
70 default class signal handler. An optional set of parameters may be specified
71 after the <em class="parameter"><code>handler</code></em> parameter. These will all be passed
72 to the signal handler when invoked.</p><p>For example if a function handler was connected to a signal
73 using:</p><pre class="programlisting">
74   handler_id = object.connect("signal_name", handler, arg1, arg2, arg3)
75 </pre><p>The handler should be defined as:</p><pre class="programlisting">
76   def handler(object, arg1, arg2, arg3):
77 </pre><p>A method handler connected to a signal using:</p><pre class="programlisting">
78   handler_id = object.connect("signal_name", self.handler, arg1, arg2)
79 </pre><p>requires an additional argument when defined:</p><pre class="programlisting">
80   def handler(self, object, arg1, arg2)
81 </pre><p>A <code class="exceptionname">TypeError</code> exception is raised
82 if <em class="parameter"><code>detailed_signal</code></em> identifies a signal name that is
83 not associated with the object.</p></div><div class="refsect2" title="gobject.GObject.connect_after"><a name="method-gobject--connect-after"></a><h3>gobject.GObject.connect_after</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">connect_after</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>handler</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>detailed_signal</code></em> :</span></p></td><td>a string containing the signal
84 name</td></tr><tr><td><p><span class="term"><em class="parameter"><code>handler</code></em> :</span></p></td><td>a Python function or method
85 object</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional optional
86 parameters</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>an integer handler
87 identifier</td></tr></tbody></table><p>The <code class="methodname">connect_after</code>() method is similar
88 to the <code class="methodname">connect</code>() method except that the
89 <em class="parameter"><code>handler</code></em> is added to the signal handler list after the
90 default class signal handler. Otherwise the details of
91 <em class="parameter"><code>handler</code></em> definition and invocation are the
92 same.</p></div><div class="refsect2" title="gobject.GObject.connect_object"><a name="method-gobject--connect-object"></a><h3>gobject.GObject.connect_object</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">connect_object</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>handler</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>gobject</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>detailed_signal</code></em> :</span></p></td><td>a string containing the signal
93 name</td></tr><tr><td><p><span class="term"><em class="parameter"><code>handler</code></em> :</span></p></td><td>a Python function or method
94 object</td></tr><tr><td><p><span class="term"><em class="parameter"><code>gobject</code></em> :</span></p></td><td>a GObject</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>an integer handler
95 identifier</td></tr></tbody></table><p>The <code class="methodname">connect_object</code>() method is the same
96 as the <code class="methodname">connect</code>() method except that the
97 <em class="parameter"><code>handler</code></em> is invoked with the specified
98 <em class="parameter"><code>gobject</code></em> in place of the object invoking the
99 <code class="methodname">connect_object</code>() method. For example, a call with a
100 function handler:</p><pre class="programlisting">
101   handler_id = object("signal_name", handler, gobject)
102 </pre><p>will cause the <em class="parameter"><code>handler</code></em> to be invoked
103 as:</p><pre class="programlisting">
104   handler(gobject)
105 </pre><p>Likewise a method handler will be invoked as:</p><pre class="programlisting">
106   self.handler(gobject)
107 </pre><p>This can be helpful in invoking PyGTK widget methods that
108 require no arguments except the widget itself (e.g.
109 <code class="methodname">widget.destroy</code>()) by using the class method as the
110 handler. For example, a Button "clicked" signal can be set up to invoke the
111 Window <code class="methodname">destroy</code>() method as:</p><pre class="programlisting">
112   handler_id = button.connect_object("clicked", Window.destroy, window)
113 </pre><p>When the button is clicked the handler is invoked as:</p><pre class="programlisting">
114   Window.destroy(window)
115 </pre><p>which is the same as:</p><pre class="programlisting">
116   window.destroy()
117 </pre><p>Additional arguments may be passed to the handler as with the
118 <code class="methodname">connect</code>() method handler invocations.</p></div><div class="refsect2" title="gobject.GObject.connect_object_after"><a name="method-gobject--connect-object-after"></a><h3>gobject.GObject.connect_object_after</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">connect_object_after</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>handler</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>detailed_signal</code></em> :</span></p></td><td>a string containing the signal
119 name</td></tr><tr><td><p><span class="term"><em class="parameter"><code>handler</code></em> :</span></p></td><td>a Python function or method
120 object</td></tr><tr><td><p><span class="term"><em class="parameter"><code>gobject</code></em> :</span></p></td><td>a GObject</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>an integer handler
121 identifier</td></tr></tbody></table><p>The <code class="methodname">connect_object_after</code>() method is
122 similar to the <code class="methodname">connect_object</code>() method except that
123 the <em class="parameter"><code>handler</code></em> is added to the signal handler list after
124 the default class signal handler. Otherwise the details of
125 <em class="parameter"><code>handler</code></em> definition and invocation are the
126 same.</p></div><div class="refsect2" title="gobject.GObject.disconnect"><a name="method-gobject--disconnect"></a><h3>gobject.GObject.disconnect</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">disconnect</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>handler_id</code></em> :</span></p></td><td>an integer handler
127 identifier</td></tr></tbody></table><p>The <code class="methodname">disconnect</code>() method removes the
128 signal handler with the specified <em class="parameter"><code>handler_id</code></em> from the
129 list of signal handlers for the object.</p></div><div class="refsect2" title="gobject.GObject.handler_disconnect"><a name="method-gobject--handler-disconnect"></a><h3>gobject.GObject.handler_disconnect</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">handler_disconnect</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>handler_id</code></em> :</span></p></td><td>an integer handler
130 identifier</td></tr></tbody></table><p>The <code class="methodname">handler_disconnect</code>() method removes
131 the signal handler with the specified <em class="parameter"><code>handler_id</code></em> from
132 the list of signal handlers for the object.</p></div><div class="refsect2" title="gobject.GObject.handler_is_connected"><a name="method-gobject--handler-is-connected"></a><h3>gobject.GObject.handler_is_connected</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">handler_is_connected</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>handler_id</code></em> :</span></p></td><td>an integer handler
133 identifier</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> if the signal handler
134 is connected to the object.</td></tr></tbody></table><p>The <code class="methodname">handler_is_connected</code>() method
135 returns <code class="literal">True</code> if the signal handler with the specified
136 <em class="parameter"><code>handler_id</code></em> is connected to the object.</p></div><div class="refsect2" title="gobject.GObject.handler_block"><a name="method-gobject--handler-block"></a><h3>gobject.GObject.handler_block</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">handler_block</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>handler_id</code></em> :</span></p></td><td>an integer handler
137 identifier</td></tr></tbody></table><p>The <code class="methodname">handler_block</code>() method blocks the
138 signal handler with the specified <em class="parameter"><code>handler_id</code></em> from
139 being invoked until it is unblocked.</p></div><div class="refsect2" title="gobject.GObject.handler_unblock"><a name="method-gobject--handler-unblock"></a><h3>gobject.GObject.handler_unblock</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">handler_unblock</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>handler_id</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>handler_id</code></em> :</span></p></td><td>an integer handler
140 identifier</td></tr></tbody></table></div><div class="refsect2" title="gobject.GObject.handler_block_by_func"><a name="method-gobject--handler-block-by-func"></a><h3>gobject.GObject.handler_block_by_func</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">handler_block_by_func</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>callable</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>callable</code></em> :</span></p></td><td>a callable python object</td></tr></tbody></table><p>The <code class="methodname">handler_block_by_func</code>() method blocks the
141 all signal handler connected to a specific <em class="parameter"><code>callable</code></em> from
142 being invoked until the callable is unblocked.</p></div><div class="refsect2" title="gobject.GObject.handler_unblock_by_func"><a name="method-gobject--handler-unblock-by-func"></a><h3>gobject.GObject.handler_unblock_by_func</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">handler_unblock_by_func</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>callback</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>callable</code></em> :</span></p></td><td>a callable python object</td></tr></tbody></table><p>The <code class="methodname">handler_unblock_by_func</code>() method unblocks
143 all signal handler connected to a specified <em class="parameter"><code>callable</code></em>
144 thereby allowing it to be invoked when the associated signals are
145 emitted.</p></div><div class="refsect2" title="gobject.GObject.emit"><a name="method-gobject--emit"></a><h3>gobject.GObject.emit</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">emit</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>detailed_signal</code></em> :</span></p></td><td>a string containing the signal
146 name</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional parameters</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a PyObject*</td></tr></tbody></table><p>The <code class="methodname">emit</code>() method causes the object to
147 emit the signal specified by <em class="parameter"><code>detailed_signal</code></em>. The
148 additional parameters must match the number and type of the required signal
149 handler parameters. In most cases no additional parameters are needed. for
150 example:</p><pre class="programlisting">
151   button.emit("clicked")
152 </pre><p>is all that is required to emit the "clicked" signal for a
153 button. The most common case requiring additional parameters occurs when
154 emitting an event signal; for example:</p><pre class="programlisting">
155   button.emit("button_press_event", event)
156 </pre></div><div class="refsect2" title="gobject.GObject.stop_emission"><a name="method-gobject--stop-emission"></a><h3>gobject.GObject.stop_emission</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">stop_emission</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>detailed_signal</code></em> :</span></p></td><td>a string containing the signal
157 name</td></tr></tbody></table><p>The <code class="methodname">stop_emission</code>() method stops the
158 current emission of the signal specified by
159 <em class="parameter"><code>detailed_signal</code></em>. Any signal handlers in the list
160 still to be run will not be invoked.</p></div><div class="refsect2" title="gobject.GObject.emit_stop_by_name"><a name="method-gobject--emit-stop-by-name"></a><h3>gobject.GObject.emit_stop_by_name</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">emit_stop_by_name</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>detailed_signal</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>detailed_signal</code></em> :</span></p></td><td>a string containing the signal
161 name</td></tr></tbody></table><p>The <code class="methodname">emit_stop_by_name</code>() method stops
162 the current emission of the signal specified by
163 <em class="parameter"><code>detailed_signal</code></em>. Any signal handlers in the list
164 still to be run will not be invoked.</p></div><div class="refsect2" title="gobject.GObject.chain"><a name="method-gobject--chain"></a><h3>gobject.GObject.chain</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">chain</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional parameters</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a Python object</td></tr></tbody></table><p>The chain() method does something.</p></div></div><div class="refsect1" title="Signals"><a name="id623647"></a><h2>Signals</h2><div class="refsect2" title='The GObject "notify" Signal'><a name="signal-gobject--notify"></a><h3>The GObject "notify" Signal</h3><pre class="programlisting"><code class="methodsynopsis">    def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>gobject</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>property_spec</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>gobject</code></em> :</span></p></td><td>the gobject that received the
165 signal</td></tr><tr><td><p><span class="term"><em class="parameter"><code>property_spec</code></em> :</span></p></td><td>the <PYGTKDOCLINK HREF="class-gobjectgparamspec"><code class="classname">gobject.GParamSpec</code></PYGTKDOCLINK> of the property that was
166 changed</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
167 with the <a class="link" href="class-gobject.html#method-gobject--connect" title="gobject.GObject.connect"><code class="methodname">connect</code>()</a>
168 method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if
169 any)</td></tr></tbody></table><p>The "notify" signal is emitted on a gobject when one of its
170 properties has been changed. Note that getting this signal doesn't guarantee
171 that the value of the property has actually changed, it may also be emitted
172 when the setter for the property is called to reinstate the previous
173 value. For example to be notified of the change of the title of a <PYGTKDOCLINK HREF="class-gtkwindow"><code class="classname">gtk.Window</code></PYGTKDOCLINK> you could
174 connect to the "notify" signal similar to:</p><pre class="programlisting">
175   window.connect("notify::title", callback)
176 </pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="gobject-class-reference.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="gobject-class-reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="class-gobjectgboxed.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">PyGObject Class Reference </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> gobject.GBoxed</td></tr></table></div></body></html>