Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically add extension for save file #43

Open
AlbertoFrancoDD opened this issue Jul 29, 2020 · 2 comments
Open

Automatically add extension for save file #43

AlbertoFrancoDD opened this issue Jul 29, 2020 · 2 comments

Comments

@AlbertoFrancoDD
Copy link

Hi
is there the chance to add the option to automatically add the extesion for the save file dialog? I have looked throught the API but I am not able to find if this is already implemented or not.

Alberto

@gamagan
Copy link

gamagan commented Mar 9, 2023

I'm sure you figured this out quickly, so I'm writing this just for posterity. The result of the file Save/Open dialogs are file paths. So, if you want to automatically add an extension to filenames, that's as simple as checking the end of the received filename for the extension, and append it, if it doesn't already have it.

@samangh
Copy link

samangh commented Mar 10, 2023

First of all, thanks @samhocevar for this library. Very useful.

As you said, it's straighforward to add the extension to the file name. However, there are two issues:

  1. We can't tell if the user chose not to add an extension on purpose or not.

  2. The file overwrite dialog. Let's say that a file test.dat already exists. Now if the user chooses test, the overwite warning dialog is not shown even though the file will actually get overwritten after we add the .dat extention.

  3. If multiple extentions are possible (e.g. there is more than one file exention filter). Because the extenion is not added to path, we have no idea which of the possilbe extentions to use.

I can look into this and do a pull request if you wish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants