Gtk.FileChooserWidget
Gtk.FileChooserWidget — A file chooser widget
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Container
╰── Gtk.Box
╰── Gtk.FileChooserWidget
See also:
Functions:
- new
(action:Gtk.FileChooserAction) -> Gtk.Widget
Signals:
- “desktop-folder”
(widget, user_data)
- “down-folder”
(widget, user_data)
- “home-folder”
(widget, user_data)
- “location-popup”
(widget, path, user_data)
- “location-popup-on-paste”
(widget, user_data)
- “location-toggle-popup”
(widget, user_data)
- “places-shortcut”
(widget, user_data)
- “quick-bookmark”
(widget, bookmark_index, user_data)
- “recent-shortcut”
(widget, user_data)
- “search-shortcut”
(widget, user_data)
- “show-hidden”
(widget, user_data)
Description:
Gtk.FileChooserWidget
is a widget for choosing files.
It exposes the Gtk.FileChooser interface, and you should use the methods of this interface to interact with the widget.
Function Details:
new()
new (action:Gtk.FileChooserAction) -> Gtk.Widget
Creates a new Gtk.FileChooserWidget
. This is a file chooser widget that canbe embedded in custom windows, and it is the same widget that is used byGtk.FileChooserDialog
.
Returns: a new Gtk.FileChooserWidget
Since: 2.4
Example:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
def file_selected(button):
print("Selected file: %s" % filechooserwidget.get_filename())
Gtk.main_quit()
window = Gtk.Window()
window.set_title("FileChooserWidget")
window.set_default_size(600, 400)
window.connect("destroy", Gtk.main_quit)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
window.add(box)
filechooserwidget = Gtk.FileChooserWidget(action=Gtk.FileChooserAction.OPEN)
box.pack_start(filechooserwidget, True, True, 0)
buttonbox = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL)
buttonbox.set_layout(Gtk.ButtonBoxStyle.END)
buttonbox.set_spacing(2)
box.pack_start(buttonbox, False, False, 0)
button = Gtk.Button(label="_Open", use_underline=True)
button.connect("clicked", file_selected)
buttonbox.add(button)
window.show_all()
Gtk.main()