This file is indexed.

/usr/share/doc/python-gtk2-tutorial/html/sec-ScrolledWindows.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
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>10.9. Scrolled Windows</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-ContainerWidgets.html" title="Chapter 10. Container Widgets"><link rel="previous" href="sec-Viewports.html" title="10.8. Viewports"><link rel="next" href="sec-ButtonBoxes.html" title="10.10. Button Boxes"></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">10.9. Scrolled Windows</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-Viewports.html">Prev</a> </td><th width="60%" align="center">Chapter 10. Container Widgets</th><td width="20%" align="right"> <a accesskey="n" href="sec-ButtonBoxes.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-ScrolledWindows"></a>10.9. Scrolled Windows</h2></div></div><div></div></div><p>Scrolled windows are used to create a scrollable area with
another widget inside it. You may insert any type of widget into a scrolled
window, and it will be accessible regardless of the size by using the
scrollbars.</p><p>The following function is used to create a new scrolled
window.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  scrolled_window = gtk.ScrolledWindow(<b class="parameter"><tt>hadjustment</tt></b>=None, <b class="parameter"><tt>vadjustment</tt></b>=None)
</pre></td></tr></table><p>Where the first argument is the adjustment for the horizontal
direction, and the second, the adjustment for the vertical direction. These
are almost always set to <tt class="literal">None</tt> or not specified.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  scrolled_window.set_policy(<b class="parameter"><tt>hscrollbar_policy</tt></b>, <b class="parameter"><tt>vscrollbar_policy</tt></b>)
</pre></td></tr></table><p>This method sets the policy to be used with respect to the
scrollbars. The first argument sets the policy for the horizontal scrollbar,
and the second, the policy for the vertical scrollbar.</p><p>The policy may be one of <tt class="literal">POLICY_AUTOMATIC</tt> or
<tt class="literal">POLICY_ALWAYS</tt>.  <tt class="literal">POLICY_AUTOMATIC</tt> will
automatically decide whether you need scrollbars, whereas
<tt class="literal">POLICY_ALWAYS</tt> will always leave the scrollbars
there.</p><p>You can then place your object into the scrolled window using
the following method.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  scrolled_window.add_with_viewport(<b class="parameter"><tt>child</tt></b>)
</pre></td></tr></table><p>The <a href="examples/scrolledwin.py" target="_top"><span><b class="command">scrolledwin.py</b></span></a>
example program packs a table with 100 toggle buttons into a scrolled
window. I've only commented on the parts that may be new to you.
<a href="sec-ScrolledWindows.html#scrolledwin" title="Figure 10.7. Scrolled Window Example">Figure 10.7, &#8220;Scrolled Window Example&#8221;</a> illustrates the program display:</p><div class="figure"><a name="scrolledwin"></a><p class="title"><b>Figure 10.7. Scrolled Window Example</b></p><div class="mediaobject" align="center"><img src="figures/scrolledwin.png" align="middle" alt="Scrolled Window Example"></div></div><p>The source code for the <a href="examples/scrolledwin.py" target="_top"><span><b class="command">scrolledwin.py</b></span></a>
program is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
    1	#!/usr/bin/env python
    2	
    3	# example scrolledwin.py
    4	
    5	import pygtk
    6	pygtk.require('2.0')
    7	import gtk
    8	
    9	class ScrolledWindowExample:
   10	    def destroy(self, widget):
   11	        gtk.main_quit()
   12	
   13	    def __init__(self):
   14	        # Create a new dialog window for the scrolled window to be
   15	        # packed into. 
   16	        window = gtk.Dialog()
   17	        window.connect("destroy", self.destroy)
   18	        window.set_title("ScrolledWindow example")
   19	        window.set_border_width(0)
   20	        window.set_size_request(300, 300)
   21	
   22	        # create a new scrolled window.
   23	        scrolled_window = gtk.ScrolledWindow()
   24	        scrolled_window.set_border_width(10)
   25	
   26	        # the policy is one of POLICY AUTOMATIC, or POLICY_ALWAYS.
   27	        # POLICY_AUTOMATIC will automatically decide whether you need
   28	        # scrollbars, whereas POLICY_ALWAYS will always leave the scrollbars
   29	        # there. The first one is the horizontal scrollbar, the second, the
   30	        # vertical.
   31	        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
   32	
   33	        # The dialog window is created with a vbox packed into it.
   34	        window.vbox.pack_start(scrolled_window, True, True, 0)
   35	        scrolled_window.show()
   36	    
   37	        # create a table of 10 by 10 squares.
   38	        table = gtk.Table(10, 10, False)
   39	
   40	        # set the spacing to 10 on x and 10 on y
   41	        table.set_row_spacings(10)
   42	        table.set_col_spacings(10)
   43	
   44	        # pack the table into the scrolled window
   45	        scrolled_window.add_with_viewport(table)
   46	        table.show()
   47	
   48	        # this simply creates a grid of toggle buttons on the table
   49	        # to demonstrate the scrolled window.
   50	        for i in range(10):
   51	            for j in range(10):
   52	                buffer = "button (%d,%d)" % (i, j)
   53	                button = gtk.ToggleButton(buffer)
   54	                table.attach(button, i, i+1, j, j+1)
   55	                button.show()
   56	
   57	        # Add a "close" button to the bottom of the dialog
   58	        button = gtk.Button("close")
   59	        button.connect_object("clicked", self.destroy, window)
   60	
   61	        # this makes it so the button is the default.
   62	        button.set_flags(gtk.CAN_DEFAULT)
   63	        window.action_area.pack_start( button, True, True, 0)
   64	
   65	        # This grabs this button to be the default button. Simply hitting
   66	        # the "Enter" key will cause this button to activate.
   67	        button.grab_default()
   68	        button.show()
   69	        window.show()
   70	
   71	def main():
   72	    gtk.main()
   73	    return 0
   74	
   75	if __name__ == "__main__":
   76	    ScrolledWindowExample()
   77	    main()
</pre></td></tr></table><p>Try resizing the window. You'll notice how the scrollbars react.
You may also wish to use the <tt class="methodname">set_size_request</tt>()
method to set the default size of the window or other widgets.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-Viewports.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch-ContainerWidgets.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-ButtonBoxes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">10.8. Viewports </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 10.10. Button Boxes</td></tr></table></div></body></html>