/usr/share/doc/python-gtk2-tutorial/html/sec-FileSelections.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 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>9.14. File Selections</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-ColorSelection.html" title="9.13. Color Selection"><link rel="next" href="sec-FontSelectionDialog.html" title="9.15. Font Selection Dialog"></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.14. File Selections</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-ColorSelection.html">Prev</a> </td><th width="60%" align="center">Chapter 9. Miscellaneous Widgets</th><td width="20%" align="right"> <a accesskey="n" href="sec-FontSelectionDialog.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-FileSelections"></a>9.14. File Selections</h2></div></div><div></div></div><p>The file selection widget is a quick and simple way to display a
File dialog box. It comes complete with <span class="guibutton">Ok</span>,
<span class="guibutton">Cancel</span>, and <span class="guibutton">Help</span> buttons, a
great way to cut down on programming time.</p><p>To create a new file selection box use:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
filesel = gtk.FileSelection(<b class="parameter"><tt>title</tt></b>=None)
</pre></td></tr></table><p>To set the filename, for example to bring up a specific
directory, or give a default filename, use this method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
filesel.set_filename(<b class="parameter"><tt>filename</tt></b>)
</pre></td></tr></table><p>To grab the filename text that the user has entered or clicked
on, use this method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
filename = filesel.get_filename()
</pre></td></tr></table><p>There are also references to the widgets contained within the file
selection widget. These are the filesel attributes:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
filesel.dir_list
filesel.file_list
filesel.selection_entry
filesel.selection_text
filesel.main_vbox
filesel.ok_button
filesel.cancel_button
filesel.help_button
filesel.history_pulldown
filesel.history_menu
filesel.fileop_dialog
filesel.fileop_entry
filesel.fileop_file
filesel.fileop_c_dir
filesel.fileop_del_file
filesel.fileop_ren_file
filesel.button_area
filesel.action_area
</pre></td></tr></table><p>Most likely you will want to use the
<i class="parameter"><tt>ok_button</tt></i>, <i class="parameter"><tt>cancel_button</tt></i>, and
<i class="parameter"><tt>help_button</tt></i> attributes to connect their widget
signals to callbacks.</p><p>The <a href="examples/filesel.py" target="_top"><span><b class="command">filesel.py</b></span></a> example
program illustrates the use of the FileSelection widget. As you will see,
there is nothing much to creating a file selection widget. While in this
example the <span class="guibutton">Help</span> button appears on the screen, it
does nothing as there is not a signal attached to it. <a href="sec-FileSelections.html#fileselfig" title="Figure 9.14. File Selection Example">Figure 9.14, “File Selection Example”</a> shows the resulting display:</p><div class="figure"><a name="fileselfig"></a><p class="title"><b>Figure 9.14. File Selection Example</b></p><div class="mediaobject" align="center"><img src="figures/fileselection.png" align="middle" alt="File Selection Example"></div></div><p>The source code for filesel.py is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
1 #!/usr/bin/env python
2
3 # example filesel.py
4
5 import pygtk
6 pygtk.require('2.0')
7 import gtk
8
9 class FileSelectionExample:
10 # Get the selected filename and print it to the console
11 def file_ok_sel(self, w):
12 print "%s" % self.filew.get_filename()
13
14 def destroy(self, widget):
15 gtk.main_quit()
16
17 def __init__(self):
18 # Create a new file selection widget
19 self.filew = gtk.FileSelection("File selection")
20
21 self.filew.connect("destroy", self.destroy)
22 # Connect the ok_button to file_ok_sel method
23 self.filew.ok_button.connect("clicked", self.file_ok_sel)
24
25 # Connect the cancel_button to destroy the widget
26 self.filew.cancel_button.connect("clicked",
27 lambda w: self.filew.destroy())
28
29 # Lets set the filename, as if this were a save dialog,
30 # and we are giving a default filename
31 self.filew.set_filename("penguin.png")
32
33 self.filew.show()
34
35 def main():
36 gtk.main()
37 return 0
38
39 if __name__ == "__main__":
40 FileSelectionExample()
41 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-ColorSelection.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-FontSelectionDialog.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">9.13. Color Selection </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 9.15. Font Selection Dialog</td></tr></table></div></body></html>
|