This file is indexed.

/usr/share/doc/python-gtk2-tutorial/html/sec-Images.html is in python-gtk2-tutorial 2.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>9.6. Images</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PyGTK 2.0 Tutorial"><link rel="up" href="ch-MiscellaneousWidgets.html" title="Chapter 9. Miscellaneous Widgets"><link rel="previous" href="sec-Dialogs.html" title="9.5. Dialogs"><link rel="next" href="sec-Rulers.html" title="9.7. Rulers"></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">9.6. Images</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-Dialogs.html">Prev</a> </td><th width="60%" align="center">Chapter 9. Miscellaneous Widgets</th><td width="20%" align="right"> <a accesskey="n" href="sec-Rulers.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-Images"></a>9.6. Images</h2></div></div><div></div></div><p><tt class="classname">Images</tt> are data structures that contain
pictures. These pictures can be used in various places.</p><p><tt class="classname">Images</tt> can be created from
<tt class="classname">Pixbufs</tt>, <tt class="classname">Pixmaps</tt>, image files
(e.g. XPM, PNG, JPEG, TIFF, etc.) and even animation files.</p><p><tt class="classname">Images</tt> are created using the
function:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  image = gtk.Image()
</pre></td></tr></table><p>The image is then loaded using one of the following
methods:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  image.set_from_pixbuf(<b class="parameter"><tt>pixbuf</tt></b>)
  image.set_from_pixmap(<b class="parameter"><tt>pixmap</tt></b>, <b class="parameter"><tt>mask</tt></b>)
  image.set_from_image(<b class="parameter"><tt>image</tt></b>)
  image.set_from_file(<b class="parameter"><tt>filename</tt></b>)
  image.set_from_stock<b class="parameter"><tt>(stock_id</tt></b>, <b class="parameter"><tt>size</tt></b>)
  image.set_from_icon_set(<b class="parameter"><tt>icon_set</tt></b>, <b class="parameter"><tt>size</tt></b>)
  image.set_from_animation(<b class="parameter"><tt>animation</tt></b>)
</pre></td></tr></table><p>Where <i class="parameter"><tt>pixbuf</tt></i> is a
<tt class="classname">gtk.gdk.Pixbuf</tt>; <i class="parameter"><tt>pixmap</tt></i> and
<i class="parameter"><tt>mask</tt></i> are <tt class="classname">gtk.gdk.Pixmaps</tt>;
<i class="parameter"><tt>image</tt></i> is a <tt class="classname">gtk.gdk.Image</tt>;
<i class="parameter"><tt>stock_id</tt></i> is the name of a
<tt class="classname">gtk.StockItem</tt>; <i class="parameter"><tt>icon_set</tt></i> is a
<tt class="classname">gtk.IconSet</tt>; and, <i class="parameter"><tt>animation</tt></i> is
a <tt class="classname">gtk.gdk.PixbufAnimation</tt>. the
<i class="parameter"><tt>size</tt></i> argument is one of:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
 ICON_SIZE_MENU
 ICON_SIZE_SMALL_TOOLBAR
 ICON_SIZE_LARGE_TOOLBAR
 ICON_SIZE_BUTTON
 ICON_SIZE_DND
 ICON_SIZE_DIALOG
</pre></td></tr></table><p>The easiest way to create an image is using the
<tt class="methodname">set_from_file</tt>() method which automatically
determines the image type and loads it.</p><p>The program <a href="examples/images.py" target="_top"><span><b class="command">images.py</b></span></a> illustrates
loading various image types (<a href="examples/goalie.gif" target="_top"><tt class="filename">goalie.gif</tt></a>, <a href="examples/apple-red.png" target="_top"><tt class="filename">apple-red.png</tt></a>,
<a href="examples/chaos.jpg" target="_top"><tt class="filename">chaos.jpg</tt></a>,
<a href="examples/important.tif" target="_top"><tt class="filename">important.tif</tt></a>,
<a href="examples/soccerball.gif" target="_top"><tt class="filename">soccerball.gif</tt></a>)
into images which are then put into buttons:</p><div class="figure"><a name="imagesfig"></a><p class="title"><b>Figure 9.5. Example Images in Buttons</b></p><div class="mediaobject" align="center"><img src="figures/images.png" align="middle" alt="Example Images in Buttons"></div></div><p>The source code is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
    1	#!/usr/bin/env python
    2	
    3	# example images.py
    4	
    5	import pygtk
    6	pygtk.require('2.0')
    7	import gtk
    8	
    9	class ImagesExample:
   10	    # when invoked (via signal delete_event), terminates the application.
   11	    def close_application(self, widget, event, data=None):
   12	        gtk.main_quit()
   13	        return False
   14	
   15	    # is invoked when the button is clicked.  It just prints a message.
   16	    def button_clicked(self, widget, data=None):
   17	        print "button %s clicked" % data
   18	
   19	    def __init__(self):
   20	        # create the main window, and attach delete_event signal to terminating
   21	        # the application
   22	        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
   23	        window.connect("delete_event", self.close_application)
   24	        window.set_border_width(10)
   25	        window.show()
   26	
   27	        # a horizontal box to hold the buttons
   28	        hbox = gtk.HBox()
   29	        hbox.show()
   30	        window.add(hbox)
   31	
   32	        pixbufanim = gtk.gdk.PixbufAnimation("goalie.gif")
   33	        image = gtk.Image()
   34	        image.set_from_animation(pixbufanim)
   35	        image.show()
   36	        # a button to contain the image widget
   37	        button = gtk.Button()
   38	        button.add(image)
   39	        button.show()
   40	        hbox.pack_start(button)
   41	        button.connect("clicked", self.button_clicked, "1")
   42	        
   43	        # create several images with data from files and load images into
   44	        # buttons
   45	        image = gtk.Image()
   46	        image.set_from_file("apple-red.png")
   47	        image.show()
   48	        # a button to contain the image widget
   49	        button = gtk.Button()
   50	        button.add(image)
   51	        button.show()
   52	        hbox.pack_start(button)
   53	        button.connect("clicked", self.button_clicked, "2")
   54	
   55	        image = gtk.Image()
   56	        image.set_from_file("chaos.jpg")
   57	        image.show()
   58	        # a button to contain the image widget
   59	        button = gtk.Button()
   60	        button.add(image)
   61	        button.show()
   62	        hbox.pack_start(button)
   63	        button.connect("clicked", self.button_clicked, "3")
   64	
   65	        image = gtk.Image()
   66	        image.set_from_file("important.tif")
   67	        image.show()
   68	        # a button to contain the image widget
   69	        button = gtk.Button()
   70	        button.add(image)
   71	        button.show()
   72	        hbox.pack_start(button)
   73	        button.connect("clicked", self.button_clicked, "4")
   74	
   75	        image = gtk.Image()
   76	        image.set_from_file("soccerball.gif")
   77	        image.show()
   78	        # a button to contain the image widget
   79	        button = gtk.Button()
   80	        button.add(image)
   81	        button.show()
   82	        hbox.pack_start(button)
   83	        button.connect("clicked", self.button_clicked, "5")
   84	
   85	
   86	def main():
   87	    gtk.main()
   88	    return 0
   89	
   90	if __name__ == "__main__":
   91	    ImagesExample()
   92	    main()
</pre></td></tr></table><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id3109973"></a>9.6.1. Pixmaps</h3></div></div><div></div></div><p><tt class="classname">Pixmaps</tt> are data structures that
contain pictures. These pictures can be used in various places, but most
commonly as icons on the X desktop, or as cursors.</p><p>A pixmap which only has 2 colors is called a bitmap, and there
are a few additional routines for handling this common special case.</p><p>To understand pixmaps, it would help to understand how X
window system works. Under X, applications do not need to be running on the
same computer that is interacting with the user. Instead, the various
applications, called "clients", all communicate with a program which
displays the graphics and handles the keyboard and mouse. This program which
interacts directly with the user is called a "display server" or "X server."
Since the communication might take place over a network, it's important to
keep some information with the X server. <tt class="classname">Pixmaps</tt>, for
example, are stored in the memory of the X server. This means that once
pixmap values are set, they don't need to keep getting transmitted over the
network; instead a command is sent to "display pixmap number XYZ here." Even
if you aren't using X with GTK+ currently, using constructs such as
<tt class="classname">Pixmaps</tt> will make your programs work acceptably under
X.</p><p>To use pixmaps in PyGTK, we must first build a
<tt class="classname">gtk.gdk.Pixmap</tt> using gtk.gdk functions in PyGTK.
<tt class="classname">Pixmaps</tt> can either be created from in-memory data, or
from data read from a file. We'll go through each of the calls to create a
pixmap.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  pixmap = gtk.gdk.pixmap_create_from_data(<b class="parameter"><tt>window</tt></b>, <b class="parameter"><tt>data</tt></b>, <b class="parameter"><tt>width</tt></b>, <b class="parameter"><tt>height</tt></b>, <b class="parameter"><tt>depth</tt></b>, <b class="parameter"><tt>fg</tt></b>, <b class="parameter"><tt>bg</tt></b>)
</pre></td></tr></table><p>This routine is used to create a <i class="parameter"><tt>pixmap</tt></i>
from <i class="parameter"><tt>data</tt></i> in memory with the color depth given by
<i class="parameter"><tt>depth</tt></i>. If <i class="parameter"><tt>depth</tt></i> is -1 the
color depth is derived from the depth of <i class="parameter"><tt>window</tt></i>. Each
pixel uses <i class="parameter"><tt>depth</tt></i> bits of data to represent the
color. <i class="parameter"><tt>Width</tt></i> and <i class="parameter"><tt>height</tt></i> are in
pixels. The <i class="parameter"><tt>window</tt></i> argument must refer to a realized
<tt class="classname">gtk.gdk.Window</tt>, since a pixmap's resources are
meaningful only in the context of the screen where it is to be
displayed. <i class="parameter"><tt>fg</tt></i> and <i class="parameter"><tt>bg</tt></i> are the
foreground and background colors of the pixmap.</p><p>Pixmaps can be created from XPM files using:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  pixmap, mask = gtk.gdk.pixmap_create_from_xpm(<b class="parameter"><tt>window</tt></b>, <b class="parameter"><tt>transparent_color</tt></b>, <b class="parameter"><tt>filename</tt></b>)
</pre></td></tr></table><p>XPM format is a readable pixmap representation for the X
Window System. It is widely used and many different utilities are available
for creating image files in this format. In the
<tt class="function">pixmap_create_from_xpm</tt>() function the first argument is
a <tt class="classname">gtk.gdk.Window</tt> type. (Most GTK+ widgets have an
underlying <tt class="classname">gtk.gdk.Window</tt> which can be retrieved by
using the widget's window attribute.) The file, specified by
<i class="parameter"><tt>filename</tt></i>, must contain an image in the XPM format and
the image is loaded into the <i class="parameter"><tt>pixmap</tt></i> structure. The
<i class="parameter"><tt>mask</tt></i> is a bitmap that specifies which bits of
<i class="parameter"><tt>pixmap</tt></i> are opaque; it is created by the function. All
other pixels are colored using the color specified by
<i class="parameter"><tt>transparent_color</tt></i>. An example using this function is
below.</p><p>Pixmaps can also be created from data in memory using the
function:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  pixmap, mask = gtk.gdk.pixmap_create_from_xpm_d(<b class="parameter"><tt>window</tt></b>, <b class="parameter"><tt>transparent_color</tt></b>, <b class="parameter"><tt>data</tt></b>)
</pre></td></tr></table><p>Small images can be incorporated into a program as data in the
XPM format using the above function. A pixmap is created using this data,
instead of reading it from a file. An example of such data is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  xpm_data = [
  "16 16 3 1",
  "       c None",
  ".      c #000000000000",
  "X      c #FFFFFFFFFFFF",
  "                ",
  "   ......       ",
  "   .XXX.X.      ",
  "   .XXX.XX.     ",
  "   .XXX.XXX.    ",
  "   .XXX.....    ",
  "   .XXXXXXX.    ",
  "   .XXXXXXX.    ",
  "   .XXXXXXX.    ",
  "   .XXXXXXX.    ",
  "   .XXXXXXX.    ",
  "   .XXXXXXX.    ",
  "   .XXXXXXX.    ",
  "   .........    ",
  "                ",
  "                "
  ]
</pre></td></tr></table><p>The final way to create a blank pixmap suitable for drawing
operations is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  pixmap = gtk.gdk.Pixmap(<b class="parameter"><tt>window</tt></b>, <b class="parameter"><tt>width</tt></b>, <b class="parameter"><tt>height</tt></b>, <b class="parameter"><tt>depth</tt></b>=-1)
</pre></td></tr></table><p><i class="parameter"><tt>window</tt></i> is either a
<tt class="classname">gtk.gdk.Window</tt>. or <tt class="literal">None</tt>. If
<i class="parameter"><tt>window</tt></i> is a <tt class="classname">gtk.gdk.Window</tt>
then <i class="parameter"><tt>depth</tt></i> can be -1 to indicate that the depth
should be determined from the window. If <i class="parameter"><tt>window</tt></i> is
<tt class="literal">None</tt> then the <i class="parameter"><tt>depth</tt></i> must be
specified.</p><p>The <a href="examples/pixmap.py" target="_top"><span><b class="command">pixmap.py</b></span></a> program is an
example of using a pixmap in a button.
<a href="sec-Images.html#pixmapfig" title="Figure 9.6. Pixmap in a Button Example">Figure 9.6, &#8220;Pixmap in a Button Example&#8221;</a> shows the result:</p><div class="figure"><a name="pixmapfig"></a><p class="title"><b>Figure 9.6. Pixmap in a Button Example</b></p><div class="mediaobject" align="center"><img src="figures/pixmap.png" align="middle" alt="Pixmap in a Button Example"></div></div><p>The source code is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
    1	#!/usr/bin/env python
    2	
    3	# example pixmap.py
    4	
    5	import pygtk
    6	pygtk.require('2.0')
    7	import gtk
    8	
    9	# XPM data of Open-File icon
   10	xpm_data = [
   11	"16 16 3 1",
   12	"       c None",
   13	".      c #000000000000",
   14	"X      c #FFFFFFFFFFFF",
   15	"                ",
   16	"   ......       ",
   17	"   .XXX.X.      ",
   18	"   .XXX.XX.     ",
   19	"   .XXX.XXX.    ",
   20	"   .XXX.....    ",
   21	"   .XXXXXXX.    ",
   22	"   .XXXXXXX.    ",
   23	"   .XXXXXXX.    ",
   24	"   .XXXXXXX.    ",
   25	"   .XXXXXXX.    ",
   26	"   .XXXXXXX.    ",
   27	"   .XXXXXXX.    ",
   28	"   .........    ",
   29	"                ",
   30	"                "
   31	]
   32	
   33	class PixmapExample:
   34	    # when invoked (via signal delete_event), terminates the application.
   35	    def close_application(self, widget, event, data=None):
   36	        gtk.main_quit()
   37	        return False
   38	
   39	    # is invoked when the button is clicked.  It just prints a message.
   40	    def button_clicked(self, widget, data=None):
   41	        print "button clicked"
   42	
   43	    def __init__(self):
   44	        # create the main window, and attach delete_event signal to terminating
   45	        # the application
   46	        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
   47	        window.connect("delete_event", self.close_application)
   48	        window.set_border_width(10)
   49	        window.show()
   50	
   51	        # now for the pixmap from XPM data
   52	        pixmap, mask = gtk.gdk.pixmap_create_from_xpm_d(window.window,
   53	                                                        None,
   54	                                                        xpm_data)
   55	
   56	        # an image widget to contain the pixmap
   57	        image = gtk.Image()
   58	        image.set_from_pixmap(pixmap, mask)
   59	        image.show()
   60	
   61	        # a button to contain the image widget
   62	        button = gtk.Button()
   63	        button.add(image)
   64	        window.add(button)
   65	        button.show()
   66	
   67	        button.connect("clicked", self.button_clicked)
   68	
   69	def main():
   70	    gtk.main()
   71	    return 0
   72	
   73	if __name__ == "__main__":
   74	    PixmapExample()
   75	    main()
</pre></td></tr></table><p>A disadvantage of using pixmaps is that the displayed object
is always rectangular, regardless of the image. We would like to create
desktops and applications with icons that have more natural shapes. For
example, for a game interface, we would like to have round buttons to push.
The way to do this is using shaped windows.</p><p>A shaped window is simply a pixmap where the background pixels
are transparent. This way, when the background image is multi-colored, we
don't overwrite it with a rectangular, non-matching border around our icon.
The <a href="examples/wheelbarrow.py" target="_top"><span><b class="command">wheelbarrow.py</b></span></a>
example program displays a full wheelbarrow image on the desktop.
<a href="sec-Images.html#wheelbarrowfig" title="Figure 9.7. Wheelbarrow Example Shaped Window">Figure 9.7, &#8220;Wheelbarrow Example Shaped Window&#8221;</a> shows the wheelbarrow over a terminal
window:</p><div class="figure"><a name="wheelbarrowfig"></a><p class="title"><b>Figure 9.7. Wheelbarrow Example Shaped Window</b></p><div class="mediaobject" align="center"><img src="figures/wheelbarrow.png" align="middle" alt="Wheelbarrow Example Shaped Window"></div></div><p>The source code for <a href="examples/wheelbarrow.py" target="_top"><span><b class="command">wheelbarrow.py</b></span></a>
is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
    1	#!/usr/bin/env python
    2	
    3	# example wheelbarrow.py
    4	
    5	import pygtk
    6	pygtk.require('2.0')
    7	import gtk
    8	
    9	# XPM
   10	WheelbarrowFull_xpm = [
   11	"48 48 64 1",
   12	"       c None",
   13	".      c #DF7DCF3CC71B",
   14	"X      c #965875D669A6",
   15	"o      c #71C671C671C6",
   16	"O      c #A699A289A699",
   17	"+      c #965892489658",
   18	"@      c #8E38410330C2",
   19	"#      c #D75C7DF769A6",
   20	"$      c #F7DECF3CC71B",
   21	"%      c #96588A288E38",
   22	"&amp;      c #A69992489E79",
   23	"*      c #8E3886178E38",
   24	"=      c #104008200820",
   25	"-      c #596510401040",
   26	";      c #C71B30C230C2",
   27	":      c #C71B9A699658",
   28	"&gt;      c #618561856185",
   29	",      c #20811C712081",
   30	"&lt;      c #104000000000",
   31	"1      c #861720812081",
   32	"2      c #DF7D4D344103",
   33	"3      c #79E769A671C6",
   34	"4      c #861782078617",
   35	"5      c #41033CF34103",
   36	"6      c #000000000000",
   37	"7      c #49241C711040",
   38	"8      c #492445144924",
   39	"9      c #082008200820",
   40	"0      c #69A618611861",
   41	"q      c #B6DA71C65144",
   42	"w      c #410330C238E3",
   43	"e      c #CF3CBAEAB6DA",
   44	"r      c #71C6451430C2",
   45	"t      c #EFBEDB6CD75C",
   46	"y      c #28A208200820",
   47	"u      c #186110401040",
   48	"i      c #596528A21861",
   49	"p      c #71C661855965",
   50	"a      c #A69996589658",
   51	"s      c #30C228A230C2",
   52	"d      c #BEFBA289AEBA",
   53	"f      c #596545145144",
   54	"g      c #30C230C230C2",
   55	"h      c #8E3882078617",
   56	"j      c #208118612081",
   57	"k      c #38E30C300820",
   58	"l      c #30C2208128A2",
   59	"z      c #38E328A238E3",
   60	"x      c #514438E34924",
   61	"c      c #618555555965",
   62	"v      c #30C2208130C2",
   63	"b      c #38E328A230C2",
   64	"n      c #28A228A228A2",
   65	"m      c #41032CB228A2",
   66	"M      c #104010401040",
   67	"N      c #492438E34103",
   68	"B      c #28A2208128A2",
   69	"V      c #A699596538E3",
   70	"C      c #30C21C711040",
   71	"Z      c #30C218611040",
   72	"A      c #965865955965",
   73	"S      c #618534D32081",
   74	"D      c #38E31C711040",
   75	"F      c #082000000820",
   76	"                                                ",
   77	"          .XoO                                  ",
   78	"         +@#$%o&amp;                                ",
   79	"         *=-;#::o+                              ",
   80	"           &gt;,&lt;12#:34                            ",
   81	"             45671#:X3                          ",
   82	"               +89&lt;02qwo                        ",
   83	"e*                &gt;,67;ro                       ",
   84	"ty&gt;                 459@&gt;+&amp;&amp;                    ",
   85	"$2u+                  &gt;&lt;ipas8*                  ",
   86	"%$;=*                *3:.Xa.dfg&gt;                ",
   87	"Oh$;ya             *3d.a8j,Xe.d3g8+             ",
   88	" Oh$;ka          *3d$a8lz,,xxc:.e3g54           ",
   89	"  Oh$;kO       *pd$%svbzz,sxxxxfX..&amp;wn&gt;         ",
   90	"   Oh$@mO    *3dthwlsslszjzxxxxxxx3:td8M4       ",
   91	"    Oh$@g&amp; *3d$XNlvvvlllm,mNwxxxxxxxfa.:,B*     ",
   92	"     Oh$@,Od.czlllllzlmmqV@V#V@fxxxxxxxf:%j5&amp;   ",
   93	"      Oh$1hd5lllslllCCZrV#r#:#2AxxxxxxxxxcdwM*  ",
   94	"       OXq6c.%8vvvllZZiqqApA:mq:Xxcpcxxxxxfdc9* ",
   95	"        2r&lt;6gde3bllZZrVi7S@SV77A::qApxxxxxxfdcM ",
   96	"        :,q-6MN.dfmZZrrSS:#riirDSAX@Af5xxxxxfevo",
   97	"         +A26jguXtAZZZC7iDiCCrVVii7Cmmmxxxxxx%3g",
   98	"          *#16jszN..3DZZZZrCVSA2rZrV7Dmmwxxxx&amp;en",
   99	"           p2yFvzssXe:fCZZCiiD7iiZDiDSSZwwxx8e*&gt;",
  100	"           OA1&lt;jzxwwc:$d%NDZZZZCCCZCCZZCmxxfd.B ",
  101	"            3206Bwxxszx%et.eaAp77m77mmmf3&amp;eeeg* ",
  102	"             @26MvzxNzvlbwfpdettttttttttt.c,n&amp;  ",
  103	"             *;16=lsNwwNwgsvslbwwvccc3pcfu&lt;o    ",
  104	"              p;&lt;69BvwwsszslllbBlllllllu&lt;5+     ",
  105	"              OS0y6FBlvvvzvzss,u=Blllj=54       ",
  106	"               c1-699Blvlllllu7k96MMMg4         ",
  107	"               *10y8n6FjvllllB&lt;166668           ",
  108	"                S-kg+&gt;666&lt;M&lt;996-y6n&lt;8*          ",
  109	"                p71=4 m69996kD8Z-66698&amp;&amp;        ",
  110	"                &amp;i0ycm6n4 ogk17,0&lt;6666g         ",
  111	"                 N-k-&lt;&gt;     &gt;=01-kuu666&gt;        ",
  112	"                 ,6ky&amp;      &amp;46-10ul,66,        ",
  113	"                 Ou0&lt;&gt;       o66y&lt;ulw&lt;66&amp;       ",
  114	"                  *kk5       &gt;66By7=xu664       ",
  115	"                   &lt;&lt;M4      466lj&lt;Mxu66o       ",
  116	"                   *&gt;&gt;       +66uv,zN666*       ",
  117	"                              566,xxj669        ",
  118	"                              4666FF666&gt;        ",
  119	"                               &gt;966666M         ",
  120	"                                oM6668+         ",
  121	"                                  *4            ",
  122	"                                                ",
  123	"                                                "
  124	]
  125	
  126	class WheelbarrowExample:
  127	    # When invoked (via signal delete_event), terminates the application
  128	    def close_application(self, widget, event, data=None):
  129	        gtk.main_quit()
  130	        return False
  131	
  132	    def __init__(self):
  133	        # Create the main window, and attach delete_event signal to terminate
  134	        # the application.  Note that the main window will not have a titlebar
  135	        # since we're making it a popup.
  136	        window = gtk.Window(gtk.WINDOW_POPUP)
  137	        window.connect("delete_event", self.close_application)
  138	        window.set_events(window.get_events() | gtk.gdk.BUTTON_PRESS_MASK)
  139	        window.connect("button_press_event", self.close_application)
  140	        window.show()
  141	
  142	        # Now for the pixmap and the image widget
  143	        pixmap, mask = gtk.gdk.pixmap_create_from_xpm_d(
  144	            window.window, None, WheelbarrowFull_xpm)
  145	        image = gtk.Image()
  146	        image.set_from_pixmap(pixmap, mask)
  147	        image.show()
  148	
  149	        # To display the image, we use a fixed widget to place the image
  150	        fixed = gtk.Fixed()
  151	        fixed.set_size_request(200, 200)
  152	        fixed.put(image, 0, 0)
  153	        window.add(fixed)
  154	        fixed.show()
  155	
  156	        # This masks out everything except for the image itself
  157	        window.shape_combine_mask(mask, 0, 0)
  158	    
  159	        # show the window
  160	        window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
  161	        window.show()
  162	
  163	def main():
  164	    gtk.main()
  165	    return 0
  166	
  167	if __name__ == "__main__":
  168	    WheelbarrowExample()
  169	    main()
</pre></td></tr></table><p>To make the wheelbarrow image sensitive, we attached the
"button_press_event" signal to make the program exit. Lines 138-139 make the
picture sensitive to a mouse button being pressed and connect the
<tt class="methodname">close_application</tt>() method.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-Dialogs.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch-MiscellaneousWidgets.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-Rulers.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">9.5. Dialogs </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 9.7. Rulers</td></tr></table></div></body></html>