Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the default open path for a Gtk.FileChooserWidget?

Tags:

python

gtk

If I set the current folder via the method Gtk.FileChooserWidget.set_current_folder(), the first time I open the file chooser, it opens on the location used as argument for set_current_folder()

But, if I select a file, the I re-open the file-chooser, it opens on the "most_recent_used_files".

I'd like it opens on the last selected file's folder path.

How to do it?

Thank you.

like image 337
Irr Avatar asked Dec 31 '25 10:12

Irr


1 Answers

From the docs:

Old versions of the file chooser's documentation suggested using gtk_file_chooser_set_current_folder() in various situations, with the intention of letting the application suggest a reasonable default folder. This is no longer considered to be a good policy, as now the file chooser is able to make good suggestions on its own. In general, you should only cause the file chooser to show a specific folder when it is appropriate to use gtk_file_chooser_set_filename() - i.e. when you are doing a File/Save As command and you already have a file saved somewhere.

You may or may not like the reasoning for this behavior. If you're curious about how it came about, see File chooser recent-files in the mailing list and Help the user choose a place to put a new file on the GNOME wiki.

like image 149
Micah Carrick Avatar answered Jan 02 '26 01:01

Micah Carrick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!