blob: bd12fca11d64c774cde3a12fcbb267f59f88eb65 (
plain)
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
|
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="class-glibmainloop">
<refnamediv>
<refname>glib.MainLoop</refname>
<refpurpose>an object representing the main event loop of a PyGTK
application.</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>glib.MainLoop</classname></ooclass>
<constructorsynopsis language="python">
<methodname><link linkend="constructor-glibmainloop">glib.MainLoop</link></methodname>
<methodparam><parameter>context</parameter><initializer>None</initializer></methodparam>
<methodparam><parameter>is_running</parameter><initializer>0</initializer></methodparam>
</constructorsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-glibmainloop--get-context">get_context</link></methodname>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-glibmainloop--is-running">is_running</link></methodname>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-glibmainloop--quit">quit</link></methodname>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-glibmainloop--run">run</link></methodname>
</methodsynopsis>
</classsynopsis>
</refsect1>
<refsect1>
<title>Ancestry</title>
<synopsis>+-- <link linkend="class-glibmainloop">glib.MainLoop</link>
</synopsis>
</refsect1>
<refsect1>
<title>Description</title>
<para><link
linkend="class-glibmainloop"><classname>glib.MainLoop</classname></link>
represents a main event loop. A <link
linkend="class-glibmainloop"><classname>glib.MainLoop</classname></link>
is created with the <link
linkend="constructor-glibmainloop">glib.MainLoop</link>()
constructor. After adding the initial event sources, the <link
linkend="method-glibmainloop--run"><methodname>run</methodname>()</link>
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 <link
linkend="method-glibmainloop--quit"><methodname>quit</methodname>()</link>
method to exit the main loop, and the <link
linkend="method-glibmainloop--run"><methodname>run</methodname>()</link>
method returns.</para>
<para>It is possible to create new instances of <link
linkend="class-glibmainloop"><classname>glib.MainLoop</classname></link>
recursively. This is often used in <literal>PyGTK</literal> applications
when showing modal dialog boxes. Note that event sources are associated with
a particular <link
linkend="class-glibmaincontext"><classname>glib.MainContext</classname></link>,
and will be checked and dispatched for all main loops associated with that
<link
linkend="class-glibmaincontext"><classname>glib.MainContext</classname></link>.</para>
<para><literal>PyGTK</literal> contains wrappers of some of these
functions, e.g. the <link
linkend="function-gtk--main"><function>gtk.main</function>()</link>, <link
linkend="function-gtk--main-quit"><function>gtk.main_quit</function>()</link>
and <link
linkend="function-gtk--events-pending"><function>gtk.events_pending</function>()</link>
functions.</para>
</refsect1>
<refsect1 id="constructor-glibmainloop">
<title>Constructor</title>
<programlisting><constructorsynopsis language="python">
<methodname>glib.MainLoop</methodname>
<methodparam><parameter>context</parameter><initializer>None</initializer></methodparam>
<methodparam><parameter>is_running</parameter><initializer>None</initializer></methodparam>
</constructorsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>context</parameter> :</term>
<listitem><simpara>a <link
linkend="class-glibmaincontext"><classname>glib.MainContext</classname></link>
or <literal>None</literal> to use the default
context.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>is_running</parameter> :</term>
<listitem><simpara>if <literal>TRUE</literal> indicates that the
loop is running. This is not very important since calling the <link
linkend="method-glibmainloop--run"><methodname>run</methodname>()</link>
method will set this to <literal>TRUE</literal>
anyway.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a new <link
linkend="class-glibmainloop"><classname>glib.MainLoop</classname></link>
object.</simpara></listitem>
</varlistentry>
</variablelist>
<para>Creates a new <link
linkend="class-glibmainloop"><classname>glib.MainLoop</classname></link>
object.</para>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-glibmainloop--get-context">
<title>glib.MainLoop.get_context</title>
<programlisting><methodsynopsis language="python">
<methodname>get_context</methodname>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the <link
linkend="class-glibmaincontext"><classname>glib.MainContext</classname></link>
the mainloop is associated with</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_context</methodname>() method returns the
<link
linkend="class-glibmaincontext"><classname>glib.MainContext</classname></link>
that the mainloop was created with.</para>
</refsect2>
<refsect2 id="method-glibmainloop--is-running">
<title>glib.MainLoop.is_running</title>
<programlisting><methodsynopsis language="python">
<methodname>is_running</methodname>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara><literal>TRUE</literal> if the mainloop is
currently being run.</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>is_running</methodname>() method checks to see
if the mainloop is currently being run via the <link
linkend="method-glibmainloop--run"><methodname>run</methodname>()</link>
method.</para>
</refsect2>
<refsect2 id="method-glibmainloop--quit">
<title>glib.MainLoop.quit</title>
<programlisting><methodsynopsis language="python">
<methodname>quit</methodname>
</methodsynopsis></programlisting>
<para>The <methodname>quit</methodname>() method stops the mainloop
from running. Any subsequent calls to the <link
linkend="method-glibmainloop--run"><methodname>run</methodname>()</link>
method will return immediately.</para>
</refsect2>
<refsect2 id="method-glibmainloop--run">
<title>glib.MainLoop.run</title>
<programlisting><methodsynopsis language="python">
<methodname>run</methodname>
</methodsynopsis></programlisting>
<para>The <methodname>run</methodname>() method runs a mainloop until
the <link
linkend="method-glibmainloop--quit"><methodname>quit</methodname>()</link>
method is called. If this is called for the thread of the loop's <link
linkend="class-glibmaincontext"><classname>glib.MainContext</classname></link>,
it will process events from the loop, otherwise it will simply wait.</para>
</refsect2>
</refsect1>
</refentry>
|