Search code examples
python-3.xpython-3.4gtk3filechooser

Gtk.FileChooserButton does not react to Gtk.FileChooserAction.SELECT_FOLDER


I am using the gi.repository.Gtk module to generate some GUIs.

To let the user select a folder I use the gi.repository.Gtk.FileChooserButton.
According to the Gtk3 documentation I should be able to select or create folders using the action Gtk.FileChooserAction.SELECT_FOLDERor Gtk.FileChooserAction.CREATE_FOLDER.

So the relevant code is this:

filechooser = Gtk.FileChooserButton(Gtk.FileChooserAction.CREATE_FOLDER)
filechooser.connect("file-set",update_select_folder)

def update_select_folder(*args):
    print(*args)

But I am still unable to select/create folders.( I am able to select files.)

So my Question is: How can I select/create folders using a FileChooserButton?


Solution

  • From https://developer.gnome.org/gtk3/stable/GtkFileChooser.html

    filechooser = Gtk.FileChooserButton()
    filechooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
    filechooser.set_create_folders(True)