im use
def on_openclicked(self, widget):
dialog = Gtk.FileChooserDialog("Please choose a file", self, Gtk.FileChooserAction.OPEN,(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
dialog.set_default_size(100, 50)
self.add_filters(dialog)
response = dialog.run()
if response == Gtk.ResponseType.OK:
print "Open clicked"
print "File selected: " + dialog.get_filename()
elif response == Gtk.ResponseType.CANCEL:
print "Cancel clicked"
dialog.destroy()
def add_filters(self, dialog):
filter_py = Gtk.FileFilter()
filter_py.set_name("Text files")
filter_py.add_mime_type("text/plain")
dialog.add_filter(filter_py)
filter_any = Gtk.FileFilter()
filter_any.set_name("Any files")
filter_any.add_pattern("*")
dialog.add_filter(filter_any)