/usr/share/doc/python-gtk2-tutorial/html/examples/filesel.py 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 | #!/usr/bin/env python
# example filesel.py
import pygtk
pygtk.require('2.0')
import gtk
class FileSelectionExample:
# Get the selected filename and print it to the console
def file_ok_sel(self, w):
print "%s" % self.filew.get_filename()
def destroy(self, widget):
gtk.main_quit()
def __init__(self):
# Create a new file selection widget
self.filew = gtk.FileSelection("File selection")
self.filew.connect("destroy", self.destroy)
# Connect the ok_button to file_ok_sel method
self.filew.ok_button.connect("clicked", self.file_ok_sel)
# Connect the cancel_button to destroy the widget
self.filew.cancel_button.connect("clicked",
lambda w: self.filew.destroy())
# Lets set the filename, as if this were a save dialog,
# and we are giving a default filename
self.filew.set_filename("penguin.png")
self.filew.show()
def main():
gtk.main()
return 0
if __name__ == "__main__":
FileSelectionExample()
main()
|