summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-introduction.xml
blob: 93675af74f70184642fd0aabf4d59eb46e80c591 (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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
<?xml version="1.0" standalone="no"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

  <chapter id="pygtk-introduction">
  <title>Introduction</title>

  <para>This document describes most of the <literal>PyGTK</literal> version
  2.0 through 2.10 classes and their methods and associated
  functions. Deprecated classes, functions and methods have been
  specifically left out of this reference though classes that have become
  deprecated since PyGTK 2.0 have been left in but annotated with a
  deprecation warning. This document attempts to document as much of the
  <literal>PyGTK</literal> <literal>API</literal> as possible but there are
  undoubtedly errors and omissions. If you discover any of these please file
  a bug report at <ulink
  url="http://bugzilla.gnome.org">bugzilla.gnome.org</ulink> for the
  <literal>pygtk</literal> project. Specific areas that have not been
  documented include:</para>

  <itemizedlist>
    <listitem>
      <simpara>The Cairo classes</simpara>
    </listitem>
  </itemizedlist>

  <para>This reference describes the API for <literal>PyGTK</literal> as of
  version 2.9.0+ and assumes that the additional API changes for version
  2.10 may not be significant. There will undoubtedly be changes that are
  not reflected in this reference. The differences in the API between
  version 2.0 and previous versions are denoted in this reference with a
  Note that describes the availability of the object, constructor, method or
  function. Any of these that do not have a notation can be assumed to be
  available in all versions of PyGTK from 2.0 and up. In the case of
  properties and signals the availability is dependent on the version of the
  underlying GTK+, GDK or Pango libraries. These will be annotated
  appropriately in a similar fashion. The source code must be consulted if
  this reference and your version of <literal>PyGTK</literal> seem to
  differ. You are encouraged to use the latest version of
  <literal>PyGTK</literal> that is available. See the <ulink
  url="http://www.pygtk.org"><literal>PyGTK</literal> homepage</ulink> for
  more information and more resources on how to use PyGTK as well as help in
  its development.</para>

  <para> The Reference contains a chapter for each <literal>PyGTK</literal>
  module (that corresponds to the underlying <literal>GTK+</literal>
  library) containing the class descriptions. The second chapter illustrates
  the <literal>PyGTK</literal> class hierarchy covering the gobject, gtk,
  gtk.gdk and pango modules.</para>

  <para>The class descriptions are arranged alphabetically within the
  chapters. Currently there are five module chapters:</para>

  <variablelist>
    <varlistentry>
      <term>The&nbsp;<literal>atk</literal>&nbsp;module</term>
      <listitem><simpara>The classes that are included in the
      <literal>atk</literal> module of <literal>PyGTK</literal> and are
      accessed similar to: atk.Object. These classes are the base object
      classes that provide accessibility support for the
      <literal>gtk</literal> module classes.</simpara>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>The&nbsp;<literal>gtk</literal>&nbsp;module</term>
      <listitem><simpara>The classes that are included in the
      <literal>gtk</literal> module of <literal>PyGTK</literal> and are
      accessed similar to: gtk.Widget. These classes are the "higher" level
      widget classes that provide most of the user interface widgets used
      for application development.</simpara>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>The&nbsp;<literal>gtk.gdk</literal>&nbsp;module</term>
      <listitem><simpara>The classes that are included in the
      <literal>gtk.gdk</literal> module of <literal>PyGTK</literal>. These
      classes are "lower" level classes that provide more fundamental
      capabilities that the <literal>gtk</literal> module widgets are built
      upon. These classes provide an abstract interface to the underlying
      window system (either X Window System or Microsoft Windows).</simpara>
      </listitem>
    </varlistentry>
    <varlistentry>
        <term>The&nbsp;<literal>gtk.glade</literal>&nbsp;module</term>
      <listitem><simpara>The classes that are included in the
      <literal>gtk.glade</literal> module of <literal>PyGTK</literal>. These
      classes provide access to the libglade functions that allow the
      dynamic loading of user interfaces from XML descriptions.</simpara>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>The&nbsp;<literal>pango</literal>&nbsp;module</term>
      <listitem>
	<simpara>The classes that are included in the
	<literal>pango</literal> module of <literal>PyGTK</literal>. These
	classes provide access to the Pango text layout and rendering
	engines. PyGTK supports a subset of the full Pango capability:
	mainly the high level layout capabilities exposed by the
	pango.Layout objects. The low level rendering capabilities have not
	been exposed mostly because there isn't a full GObject interface to
	the underlying Pango data structures. It's also likely that the
	rendering capabilities require more performance that Python can
	provide.</simpara>
      </listitem>
    </varlistentry>
  </variablelist>

  <para>The <literal>gobject</literal> module is documented in the <link
  linkend="pygobject-reference">PyGObject Reference Manual</link>.</para>

  <sect1>
    <title>Major Changes since Version 1.9</title>

    <para>The major changes in this document since version 1.9
include:</para>

    <itemizedlist>
      <listitem>
	<para>descriptions of new GTK+ 2.2 and 2.4 classes:</para>

	<itemizedlist>
	  <listitem>
	    <simpara><link linkend="class-gobjectgboxed"><classname>gobject.GBoxed</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gobjectgpointer"><classname>gobject.GPointer</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gobjectginterface"><classname>gobject.GInterface</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gobjectmaincontext"><classname>gobject.MainContext</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gobjectmainloop"><classname>gobject.MainLoop</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkaction"><classname>gtk.Action</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkactiongroup"><classname>gtk.ActionGroup</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkborder"><classname>gtk.Border</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkclipboard"><classname>gtk.Clipboard</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkcolorbutton"><classname>gtk.ColorButton</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkcombobox"><classname>gtk.ComboBox</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkentrycompletion"><classname>gtk.EntryCompletion</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkexpander"><classname>gtk.Expander</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkfilechooser"><classname>gtk.FileChooser</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkfilechooserdialog"><classname>gtk.FileChooserDialog</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkfilechooserwidget"><classname>gtk.FileChooserWidget</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkfilefilter"><classname>gtk.FileFilter</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkfontbutton"><classname>gtk.FontButton</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkiconinfo"><classname>gtk.IconInfo</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkicontheme"><classname>gtk.IconTheme</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkradioaction"><classname>gtk.RadioAction</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkradiotoolbutton"><classname>gtk.RadioToolButton</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkseparatortoolitem"><classname>gtk.SeparatorToolItem</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtktoggleaction"><classname>gtk.ToggleAction</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtktoggletoolbutton"><classname>gtk.ToggleToolButton</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtktoolbutton"><classname>gtk.ToolButton</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtktoolitem"><classname>gtk.ToolItem</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtktreemodelfilter"><classname>gtk.TreeModelFilter</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtktreerowreference"><classname>gtk.TreeRowReference</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gtkuimanager"><classname>gtk.UIManager</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gdkatom"><classname>gtk.gdk.Atom</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gdkdisplay"><classname>gtk.gdk.Display</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gdkdisplaymanager"><classname>gtk.gdk.DisplayManager</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link></simpara>
	  </listitem>
	  <listitem>
	    <simpara><link linkend="class-pangofontsetsimple"><classname>pango.FontsetSimple</classname></link></simpara>
	  </listitem>
	</itemizedlist>

      </listitem>
      <listitem>
        <simpara>Descriptions of new GTK+ 2.6 classes:</simpara>

        <itemizedlist>
          <listitem>
            <simpara><link linkend="class-gtkaboutdialog"><classname>gtk.AboutDialog</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkcellrenderercombo"><classname>gtk.CellRendererCombo</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkcellrendererprogress"><classname>gtk.CellRendererProgress</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkcellview"><classname>gtk.CellView</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkfilechooserbutton"><classname>gtk.FileChooserButton</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkiconview"><classname>gtk.IconView</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkmenutoolbutton"><classname>gtk.MenuToolButton</classname></link></simpara>
          </listitem>
        </itemizedlist>

      </listitem>
      <listitem>
	<para>a reference page in each module chapter containing
descriptions of or links to all of the functions defined in a module.</para>
      </listitem>
      <listitem>
	<para>a reference page in each module chapter containing
descriptions of all of the constants defined in a module.</para>
      </listitem>
      <listitem>
	<para>additional methods, functions, properties and signals added
	for GTK+ 2.2, GTK+ 2.4, GTK+ 2.6, PyGTK 2.2, PyGTK 2.4, PyGTK 2.6,
	PyGTK 2.8 and PyGTK 2.10.</para>
      </listitem>
      <listitem>
        <simpara>Descriptions of new GTK+ 2.10 classes:</simpara>

        <itemizedlist>
          <listitem>
            <simpara><link linkend="class-gtkassistant"><classname>gtk.Assistant</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkcellrendereraccel"><classname>gtk.CellRendererAccel</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkcellrendererspin"><classname>gtk.CellRendererSpin</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtklinkbutton"><classname>gtk.LinkButton</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkpagesetup"><classname>gtk.PageSetup</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkpapersize"><classname>gtk.PaperSize</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkprintcontext"><classname>gtk.PrintContext</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkprintoperation"><classname>gtk.PrintOperation</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkprintoperationpreview"><classname>gtk.PrintOperationPreview</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkprintsettings"><classname>gtk.PrintSettings</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkrecentchooserdialog"><classname>gtk.RecentChooserDialog</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkrecentchoosermenu"><classname>gtk.RecentChooserMenu</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkrecentchooserwidget"><classname>gtk.RecentChooserWidget</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkrecentchooser"><classname>gtk.RecentChooser</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkrecentfilter"><classname>gtk.RecentFilter</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkrecentinfo"><classname>gtk.RecentInfo</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkrecentmanager"><classname>gtk.RecentManager</classname></link></simpara>
          </listitem>
          <listitem>
            <simpara><link linkend="class-gtkstatusicon"><classname>gtk.StatusIcon</classname></link></simpara>
          </listitem>
        </itemizedlist>

      </listitem>
      <listitem>
	<para>new in PyGTK 2.10, the <link
	linkend="unixprint-class-reference">Unix print module
	gtkunixprint</link>.</para>
      </listitem>
      <listitem>
	<para>documentation on the <link
	linkend="atk-class-reference">Accessibilty Tool Kit
	atk</link>.</para>
      </listitem>
    </itemizedlist>

  </sect1>

  <sect1 id="pygtk-reference-format">
    <title>Reference Page Format</title>

    <para>Each <literal>PyGTK</literal> class is described in a reference
page that has a number of sections in a fixed format. Each reference page
will have a subset of the following sections:</para>

    <variablelist>
      <varlistentry>
	<term>Name</term>
	<listitem>
	  <simpara>The name and a one-line description of the
class.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Synopsis</term>
	<listitem>
	  <simpara>A synopsis of the class and its methods and
optionally a list of associated functions.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Ancestry</term>
	<listitem>
	  <simpara>The list of the parent classes of the class. This
section may not be present in all class descriptions.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Properties</term>
 	<listitem>
	  <simpara>A list of the properties (internal state)
supported by the class. This section may not be present in all classes. The
property descriptions include the name, the access operations (e.g. Read,
Write), and a brief description. Properties are accessed using the <link
linkend="method-gobject--set-property"><methodname>gobject.set_property</methodname>()</link> 
and <link
linkend="method-gobject--get-property"><methodname>gobject.get_property</methodname>()</link> 
methods that are available to every <literal>PyGTK</literal> object. This
section may not be present in all class descriptions.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Style&nbsp;Properties</term>
	<listitem>
	  <simpara>A list of style properties supported by the
class. Similar to the properties (described above) the style properties hold
information about the style of a widgets e.g. border style, shadow type,
etc. Most widgets do not support style properties so this section is not
present in most class descriptions. Only PyGTK 2.4 has the ability to access
style properties.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Child&nbsp;Properties</term>
	<listitem>
	  <simpara>A list of child properties supported by the
class. Similar to the properties (described above) the child properties hold
information about the properties of a widget's child widget. Only container
widgets support child properties so this section is not present in most
class descriptions.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Attributes</term>
	<listitem>
	  <simpara>A set of internal object state data accessible as
Python attributes (e.g. object.attr). The attribute descriptions include a
name by which the attribute data is accessed, the access mode (e.g. Read,
Write), and a brief description of the attribute. Most
<literal>PyGTK</literal> classes do not support attributes so this section
is not present in most class descriptions.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Signal&nbsp;Prototypes</term>
	<listitem>
	  <simpara>A list of the signals supported by the class
including the signal name and a synopsis of the signal handler function
prototype. This section may not be present in all class descriptions; most
<literal>gtk.gdk</literal> classes do not support signals.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Description</term>
	<listitem><simpara>A description of the class and possibly some of
the methods supported by the class.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Constructor</term>
	<listitem>
	  <simpara>The description of the class object constructor
including the synopsis with brief parameter descriptions and a description
of th use of the constructor. There may be more than one constructor
description if the constructor supports different parameter lists. This
section may not be present in all class descriptions.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Methods</term>
	<listitem>
	  <simpara>A list of methods supported by the class. Each
method description includes: a synopsis of the method and its parameters as
well as a brief description of each parameter and return value (if any);
and, a description of the use of the method.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Functions</term>
	<listitem>
	  <simpara>A list of related functions. Each function
description includes a synopsis of the function and its parameters and
return value (if any), and a description of the use of the
function.</simpara>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>Signals</term>
	<listitem>
	  <simpara>A list of signals including a synopsis of the
signal handler prototype function with its parameters and return value (if
any). The signal emission conditions are briefly described. This section is
not present in all class descriptions; specifically, the
<literal>gtk.gdk</literal> classes do not usually support signals.</simpara>
	</listitem>
      </varlistentry>
    </variablelist>

    <para>The function and method synopsis parameters are displayed in
<emphasis role="bold">bold</emphasis> to denote Python keyword parameters.
Also if the parameter is optional its default value will be displayed. For
example the <link linkend="constructor-gtkbutton">gtk.Button</link>()
constructor synopsis is:</para>

    <programlisting>
<constructorsynopsis language="python">
	<methodname><link
linkend="constructor-gtkbutton">gtk.Button</link></methodname>
	<methodparam><parameter
		       role="keyword">label</parameter><initializer>None</initializer></methodparam>
	<methodparam><parameter
		       role="keyword">stock</parameter><initializer>None</initializer></methodparam>
      </constructorsynopsis>
</programlisting>

    <para>The parameters <parameter>label</parameter> and
<parameter>stock</parameter> are keyword parameters that can be specified in
a call either by position or keyword (in which case position is not
important). The following calls have the same result:</para>

    <programlisting>
  b = gtk.Button("Cancel")
  b = gtk.Button(label="Cancel")
  b = gtk.Button("Cancel", None)
  b = gtk.Button("Cancel", stock=None)
  b = gtk.Button(stock=None, label="Cancel")
</programlisting>

    <para>Parameters that are not keyword parameters are displayed in
    <emphasis>italic</emphasis> and must be specified positionally but may
    also be optional.</para>

  </sect1>

  </chapter>