This file is indexed.

/usr/share/doc/python-gtk2-tutorial/html/sec-TextEntries.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
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>9.9. Text Entries</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-Statusbars.html" title="9.8. Statusbars"><link rel="next" href="sec-SpinButtons.html" title="9.10. Spin Buttons"></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.9. Text Entries</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-Statusbars.html">Prev</a> </td><th width="60%" align="center">Chapter 9. Miscellaneous Widgets</th><td width="20%" align="right"> <a accesskey="n" href="sec-SpinButtons.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-TextEntries"></a>9.9. Text Entries</h2></div></div><div></div></div><p>The <tt class="classname">Entry</tt> widget allows text to be typed
and displayed in a single line text box. The text may be set with method
calls that allow new text to replace, prepend or append the current contents
of the <tt class="classname">Entry</tt> widget.</p><p>The function for creating an <tt class="classname">Entry</tt> widget
is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  entry = gtk.Entry(<b class="parameter"><tt>max</tt></b>=0)
</pre></td></tr></table><p>If the <i class="parameter"><tt>max</tt></i> argument is given it sets a
limit on the length of the text within the <tt class="classname">Entry</tt>. If
<i class="parameter"><tt>max</tt></i> is 0 then there is no limit.</p><p>The maximum length of the entry can be changed using the
method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  entry.set_max_length(<b class="parameter"><tt>max</tt></b>)
</pre></td></tr></table><p>The next method alters the text which is currently within the
<tt class="classname">Entry</tt> widget.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  entry.set_text(<b class="parameter"><tt>text</tt></b>)
</pre></td></tr></table><p>The <tt class="methodname">set_text</tt>() method sets the contents
of the <tt class="classname">Entry</tt> widget to <i class="parameter"><tt>text</tt></i>,
replacing the current contents. Note that the class
<tt class="classname">Entry</tt> implements the <tt class="classname">Editable</tt>
interface (yes, <tt class="classname">gobject</tt> supports Java-like
interfaces) which contains some more functions for manipulating the
contents. For example, the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  entry.insert_text(<b class="parameter"><tt>text</tt></b>, <b class="parameter"><tt>position</tt></b>=0)
</pre></td></tr></table><p>inserts <i class="parameter"><tt>text</tt></i> at the given position within
the <i class="parameter"><tt>entry</tt></i>.</p><p>The contents of the <tt class="classname">Entry</tt> can be
retrieved by using a call to the following method. This is useful in the
callback methods described below.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  text = entry.get_text()
</pre></td></tr></table><p>If we don't want the contents of the
<tt class="classname">Entry</tt> to be changed by someone typing into it, we can
change its editable state.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  entry.set_editable(<b class="parameter"><tt>is_editable</tt></b>)
</pre></td></tr></table><p>The above method allows us to toggle the editable state of the
<tt class="classname">Entry</tt> widget by passing in a <tt class="literal">TRUE</tt>
or <tt class="literal">FALSE</tt> value for the <i class="parameter"><tt>is_editable</tt></i>
argument.</p><p>If we are using the <tt class="classname">Entry</tt> where we don't
want the text entered to be visible, for example when a password is being
entered, we can use the following method, which also takes a boolean
flag.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  entry.set_visibility(<b class="parameter"><tt>visible</tt></b>)
</pre></td></tr></table><p>A region of the text may be set as selected by using the
following method. This would most often be used after setting some default
text in an <tt class="classname">Entry</tt>, making it easy for the user to
remove it.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  entry.select_region(<b class="parameter"><tt>start</tt></b>, <b class="parameter"><tt>end</tt></b>)
</pre></td></tr></table><p>If we want to be notified when the user has entered text, we can
connect to the "activate" or "changed" signal. Activate is raised when the
user hits the enter key within the <tt class="classname">Entry</tt> widget.
Changed is raised when the any change is made to the text, e.g. for every
character entered or removed.</p><p>The <a href="examples/entry.py" target="_top"><span><b class="command">entry.py</b></span></a> example program
illustrates the use of an <tt class="classname">Entry</tt> widget.
<a href="sec-TextEntries.html#entryfig" title="Figure 9.10. Entry Example">Figure 9.10, &#8220;Entry Example&#8221;</a> shows the result of running the program:</p><div class="figure"><a name="entryfig"></a><p class="title"><b>Figure 9.10. Entry Example</b></p><div class="mediaobject" align="center"><img src="figures/entry.png" align="middle" alt="Entry Example"></div></div><p>The <a href="examples/entry.py" target="_top"><span><b class="command">entry.py</b></span></a> source code
is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
    1	#!/usr/bin/env python
    2	
    3	# example entry.py
    4	
    5	import pygtk
    6	pygtk.require('2.0')
    7	import gtk
    8	
    9	class EntryExample:
   10	    def enter_callback(self, widget, entry):
   11	        entry_text = entry.get_text()
   12	        print "Entry contents: %s\n" % entry_text
   13	
   14	    def entry_toggle_editable(self, checkbutton, entry):
   15	        entry.set_editable(checkbutton.get_active())
   16	
   17	    def entry_toggle_visibility(self, checkbutton, entry):
   18	        entry.set_visibility(checkbutton.get_active())
   19	
   20	    def __init__(self):
   21	        # create a new window
   22	        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
   23	        window.set_size_request(200, 100)
   24	        window.set_title("GTK Entry")
   25	        window.connect("delete_event", lambda w,e: gtk.main_quit())
   26	
   27	        vbox = gtk.VBox(False, 0)
   28	        window.add(vbox)
   29	        vbox.show()
   30	
   31	        entry = gtk.Entry()
   32	        entry.set_max_length(50)
   33	        entry.connect("activate", self.enter_callback, entry)
   34	        entry.set_text("hello")
   35	        entry.insert_text(" world", len(entry.get_text()))
   36	        entry.select_region(0, len(entry.get_text()))
   37	        vbox.pack_start(entry, True, True, 0)
   38	        entry.show()
   39	
   40	        hbox = gtk.HBox(False, 0)
   41	        vbox.add(hbox)
   42	        hbox.show()
   43	                                  
   44	        check = gtk.CheckButton("Editable")
   45	        hbox.pack_start(check, True, True, 0)
   46	        check.connect("toggled", self.entry_toggle_editable, entry)
   47	        check.set_active(True)
   48	        check.show()
   49	    
   50	        check = gtk.CheckButton("Visible")
   51	        hbox.pack_start(check, True, True, 0)
   52	        check.connect("toggled", self.entry_toggle_visibility, entry)
   53	        check.set_active(True)
   54	        check.show()
   55	                                   
   56	        button = gtk.Button(stock=gtk.STOCK_CLOSE)
   57	        button.connect("clicked", lambda w: gtk.main_quit())
   58	        vbox.pack_start(button, True, True, 0)
   59	        button.set_flags(gtk.CAN_DEFAULT)
   60	        button.grab_default()
   61	        button.show()
   62	        window.show()
   63	
   64	def main():
   65	    gtk.main()
   66	    return 0
   67	
   68	if __name__ == "__main__":
   69	    EntryExample()
   70	    main()
</pre></td></tr></table></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-Statusbars.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-SpinButtons.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">9.8. Statusbars </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 9.10. Spin Buttons</td></tr></table></div></body></html>