This file is indexed.

/usr/share/doc/python-gtk2-tutorial/html/sec-UpgradedHelloWorld.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
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>3.2. An Upgraded Hello World</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-MovingOn.html" title="Chapter 3. Moving On"><link rel="previous" href="ch-MovingOn.html" title="Chapter 3. Moving On"><link rel="next" href="ch-PackingWidgets.html" title="Chapter 4. Packing Widgets"></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">3.2. An Upgraded Hello World</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch-MovingOn.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Moving On</th><td width="20%" align="right"> <a accesskey="n" href="ch-PackingWidgets.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-UpgradedHelloWorld"></a>3.2. An Upgraded Hello World</h2></div></div><div></div></div><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
    1   #!/usr/bin/env python
    2
    3   # example helloworld2.py
    4
    5   import pygtk
    6   pygtk.require('2.0')
    7   import gtk
    8
    9   class HelloWorld2:
   10
   11       # Our new improved callback.  The data passed to this method
   12       # is printed to stdout.
   13       def callback(self, widget, data):
   14           print "Hello again - %s was pressed" % data
   15
   16       # another callback
   17       def delete_event(self, widget, event, data=None):
   18           gtk.main_quit()
   19           return False
   20
   21       def __init__(self):
   22           # Create a new window
   23           self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
   24
   25           # This is a new call, which just sets the title of our
   26           # new window to "Hello Buttons!"
   27           self.window.set_title("Hello Buttons!")
   28
   29           # Here we just set a handler for delete_event that immediately
   30           # exits GTK.
   31           self.window.connect("delete_event", self.delete_event)
   32
   33           # Sets the border width of the window.
   34           self.window.set_border_width(10)
   35
   36           # We create a box to pack widgets into.  This is described in detail
   37           # in the "packing" section. The box is not really visible, it
   38           # is just used as a tool to arrange widgets.
   39           self.box1 = gtk.HBox(False, 0)
   40
   41           # Put the box into the main window.
   42           self.window.add(self.box1)
   43
   44           # Creates a new button with the label "Button 1".
   45           self.button1 = gtk.Button("Button 1")
   46
   47           # Now when the button is clicked, we call the "callback" method
   48           # with a pointer to "button 1" as its argument
   49           self.button1.connect("clicked", self.callback, "button 1")
   50
   51           # Instead of add(), we pack this button into the invisible
   52           # box, which has been packed into the window.
   53           self.box1.pack_start(self.button1, True, True, 0)
   54
   55           # Always remember this step, this tells GTK that our preparation for
   56           # this button is complete, and it can now be displayed.
   57           self.button1.show()
   58
   59           # Do these same steps again to create a second button
   60           self.button2 = gtk.Button("Button 2")
   61
   62           # Call the same callback method with a different argument,
   63           # passing a pointer to "button 2" instead.
   64           self.button2.connect("clicked", self.callback, "button 2")
   65
   66           self.box1.pack_start(self.button2, True, True, 0)
   67
   68           # The order in which we show the buttons is not really important, but I
   69           # recommend showing the window last, so it all pops up at once.
   70           self.button2.show()
   71           self.box1.show()
   72           self.window.show()
   73
   74   def main():
   75       gtk.main()
   76
   77   if __name__ == "__main__":
   78       hello = HelloWorld2()
   79       main()
</pre></td></tr></table><p>Running <a href="examples/helloworld2.py" target="_top"><span><b class="command">helloworld2.py</b></span></a>
produces the window illustrated in <a href="sec-UpgradedHelloWorld.html#helloworld2fig" title="Figure 3.1. Upgraded Hello World Example">Figure 3.1, &#8220;Upgraded Hello World Example&#8221;</a>.</p><div class="figure"><a name="helloworld2fig"></a><p class="title"><b>Figure 3.1. Upgraded Hello World Example</b></p><div class="mediaobject" align="center"><img src="figures/helloworld2.png" align="middle" alt="Upgraded Hello World Example"></div></div><p>You'll notice this time there is no easy way to exit the
program, you have to use your window manager or command line to kill it. A
good exercise for the reader would be to insert a third "Quit" button that
will exit the program. You may also wish to play with the options to
<tt class="methodname">pack_start</tt>() while reading the next section. Try
resizing the window, and observe the behavior.</p><p>A short commentary on the code differences from the first
helloworld program is in order.</p><p>As noted above there is no "destroy" event handler in the
upgraded helloworld.</p><p>Lines 13-14 define a callback method which is similar to the
<tt class="methodname">hello</tt>() callback in the first helloworld. The
difference is that the callback prints a message including data passed
in.</p><p>Line 27 sets a title string to be used on the titlebar of the
window (see <a href="sec-UpgradedHelloWorld.html#helloworld2fig" title="Figure 3.1. Upgraded Hello World Example">Figure 3.1, &#8220;Upgraded Hello World Example&#8221;</a>).</p><p>Line 39 creates a horizontal box
(<tt class="classname">gtk.HBox</tt>) to hold the two buttons that are created
in lines 45 and 60. Line 42 adds the horizontal box to the window
container.</p><p>Lines 49 and 64 connect the <tt class="methodname">callback</tt>()
method to the "clicked" signal of the buttons. Each button sets up a
different string to be passed to the <tt class="methodname">callback</tt>()
method when invoked.</p><p>Lines 53 and 66 pack the buttons into the horizontal box. Lines
57 and 70 ask GTK to display the buttons.</p><p>Lines 71-72 ask GTK to display the box and the window
respectively.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch-MovingOn.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch-MovingOn.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch-PackingWidgets.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 3. Moving On </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 4. Packing Widgets</td></tr></table></div></body></html>