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
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>gobject.MainLoop</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="gobject-class-reference.html" title="The gobject Class Reference"><link rel="previous" href="class-gobjectmaincontext.html" title="gobject.MainContext"><link rel="next" href="gobject-functions.html" title="gobject Functions"></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.MainLoop</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gobjectmaincontext.html">Prev</a></td><th width="60%" align="center">The gobject Class Reference</th><td width="20%" align="right"><a accesskey="n" href="gobject-functions.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="class-gobjectmainloop"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2>gobject.MainLoop</h2><p>gobject.MainLoop — an object representing the main event loop of a PyGTK
application.</p></div><div class="refsect1" lang="en"><a name="id3014589"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gobject.MainLoop</span></span>:
<code class="constructorsynopsis"> <span class="methodname"><a href="class-gobjectmainloop.html#constructor-gobjectmainloop" title="Constructor">gobject.MainLoop</a></span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>context</tt></i></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>is_running</tt></i></span><span class="initializer">=0</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gobjectmainloop.html#method-gobjectmainloop--get-context" title="gobject.MainLoop.get_context">get_context</a></span>()</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gobjectmainloop.html#method-gobjectmainloop--is-running" title="gobject.MainLoop.is_running">is_running</a></span>()</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gobjectmainloop.html#method-gobjectmainloop--quit" title="gobject.MainLoop.quit">quit</a></span>()</code><br><code class="methodsynopsis"> def <span class="methodname"><a href="class-gobjectmainloop.html#method-gobjectmainloop--run" title="gobject.MainLoop.run">run</a></span>()</code><br></pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id3009946"></a><h2>Ancestry</h2><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="synopsis">+-- <a href="class-gobjectmainloop.html" title="gobject.MainLoop">gobject.MainLoop</a>
</pre></td></tr></table></div><div class="refsect1" lang="en"><a name="id2987377"></a><h2>Description</h2><p><a href="class-gobjectmainloop.html" title="gobject.MainLoop"><tt class="classname">gobject.MainLoop</tt></a>
represents a main event loop. A <a href="class-gobjectmainloop.html" title="gobject.MainLoop"><tt class="classname">gobject.MainLoop</tt></a>
is created with the <a href="class-gobjectmainloop.html#constructor-gobjectmainloop" title="Constructor">gobject.MainLoop</a>()
constructor. After adding the initial event sources, the <a href="class-gobjectmainloop.html#method-gobjectmainloop--run" title="gobject.MainLoop.run"><tt class="methodname">run</tt>()</a>
method is called. This continuously checks for new events from each of the
event sources and dispatches them. Finally, the processing of an event from
one of the sources leads to a call to the <a href="class-gobjectmainloop.html#method-gobjectmainloop--quit" title="gobject.MainLoop.quit"><tt class="methodname">quit</tt>()</a>
method to exit the main loop, and the <a href="class-gobjectmainloop.html#method-gobjectmainloop--run" title="gobject.MainLoop.run"><tt class="methodname">run</tt>()</a>
method returns.</p><p>It is possible to create new instances of <a href="class-gobjectmainloop.html" title="gobject.MainLoop"><tt class="classname">gobject.MainLoop</tt></a>
recursively. This is often used in <tt class="literal">PyGTK</tt> applications
when showing modal dialog boxes. Note that event sources are associated with
a particular <a href="class-gobjectmaincontext.html" title="gobject.MainContext"><tt class="classname">gobject.MainContext</tt></a>,
and will be checked and dispatched for all main loops associated with that
<a href="class-gobjectmaincontext.html" title="gobject.MainContext"><tt class="classname">gobject.MainContext</tt></a>.</p><p><tt class="literal">PyGTK</tt> contains wrappers of some of these
functions, e.g. the <a href="gtk-functions.html#function-gtk--main" title="gtk.main"><tt class="function">gtk.main</tt>()</a>, <a href="gtk-functions.html#function-gtk--main-quit" title="gtk.main_quit"><tt class="function">gtk.main_quit</tt>()</a>
and <a href="gtk-functions.html#function-gtk--events-pending" title="gtk.events_pending"><tt class="function">gtk.events_pending</tt>()</a>
functions.</p></div><div class="refsect1" lang="en"><a name="constructor-gobjectmainloop"></a><h2>Constructor</h2><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="constructorsynopsis"> <span class="methodname">gobject.MainLoop</span>(<span class="methodparam"><span class="parameter"><i class="parameter"><tt>context</tt></i></span><span class="initializer">=None</span></span>, <span class="methodparam"><span class="parameter"><i class="parameter"><tt>is_running</tt></i></span><span class="initializer">=None</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>context</tt></i>:</span></td><td>a <a href="class-gobjectmaincontext.html" title="gobject.MainContext"><tt class="classname">gobject.MainContext</tt></a>
or <tt class="literal">None</tt> to use the default
context.</td></tr><tr><td><span class="term"><i class="parameter"><tt>is_running</tt></i>:</span></td><td>if <tt class="literal">TRUE</tt> indicates that the
loop is running. This is not very important since calling the <a href="class-gobjectmainloop.html#method-gobjectmainloop--run" title="gobject.MainLoop.run"><tt class="methodname">run</tt>()</a>
method will set this to <tt class="literal">TRUE</tt>
anyway.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>:</span></td><td>a new <a href="class-gobjectmainloop.html" title="gobject.MainLoop"><tt class="classname">gobject.MainLoop</tt></a>
object.</td></tr></tbody></table><p>Creates a new <a href="class-gobjectmainloop.html" title="gobject.MainLoop"><tt class="classname">gobject.MainLoop</tt></a>
object.</p></div><div class="refsect1" lang="en"><a name="id3015126"></a><h2>Methods</h2><div class="refsect2" lang="en"><a name="method-gobjectmainloop--get-context"></a><h3>gobject.MainLoop.get_context</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_context</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"><span class="emphasis"><em>Returns</em></span>:</span></td><td>the <a href="class-gobjectmaincontext.html" title="gobject.MainContext"><tt class="classname">gobject.MainContext</tt></a>
the mainloop is associated with</td></tr></tbody></table><p>The <tt class="methodname">get_context</tt>() method returns the
<a href="class-gobjectmaincontext.html" title="gobject.MainContext"><tt class="classname">gobject.MainContext</tt></a>
that the mainloop was created with.</p></div><div class="refsect2" lang="en"><a name="method-gobjectmainloop--is-running"></a><h3>gobject.MainLoop.is_running</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">is_running</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"><span class="emphasis"><em>Returns</em></span>:</span></td><td><tt class="literal">TRUE</tt> if the mainloop is
currently being run.</td></tr></tbody></table><p>The <tt class="methodname">is_running</tt>() method checks to see
if the mainloop is currently being run via the <a href="class-gobjectmainloop.html#method-gobjectmainloop--run" title="gobject.MainLoop.run"><tt class="methodname">run</tt>()</a>
method.</p></div><div class="refsect2" lang="en"><a name="method-gobjectmainloop--quit"></a><h3>gobject.MainLoop.quit</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">quit</span>()</code></pre></td></tr></table><p>The <tt class="methodname">quit</tt>() method stops the mainloop
from running. Any subsequent calls to the <a href="class-gobjectmainloop.html#method-gobjectmainloop--run" title="gobject.MainLoop.run"><tt class="methodname">run</tt>()</a>
method will return immediately.</p></div><div class="refsect2" lang="en"><a name="method-gobjectmainloop--run"></a><h3>gobject.MainLoop.run</h3><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">run</span>()</code></pre></td></tr></table><p>The <tt class="methodname">run</tt>() method runs a mainloop until
the <a href="class-gobjectmainloop.html#method-gobjectmainloop--quit" title="gobject.MainLoop.quit"><tt class="methodname">quit</tt>()</a>
method is called. If this is called for the thread of the loop's <a href="class-gobjectmaincontext.html" title="gobject.MainContext"><tt class="classname">gobject.MainContext</tt></a>,
it will process events from the loop, otherwise it will simply wait.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="class-gobjectmaincontext.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="gobject-functions.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gobject.MainContext</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">gobject Functions</td></tr></table></div></body></html>
|