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

Mu Editor 1.1.0b4 does not add the file extension .py when saving a new file for the first time on Linux #1571

Closed
amos1969 opened this issue May 17, 2021 · 4 comments · Fixed by #1572
Labels
Milestone

Comments

@amos1969
Copy link
Contributor

amos1969 commented May 17, 2021

Steps to recreate:

  1. Install the latest beta via pip in a virtual environment (Kubuntu 21.04 using a Python 3.8.10 virtual environment via pyenv).
  2. Start the Mu Editor as normal.
  3. Click on New to create a new tab.
  4. Click on Save and in the resulting dialog box, enter a file name for the file, but do not add the .py extension and hit enter.

Expected behaviour

File saves with the .py extension added automatically.

Actual behaviour

File saves as a plain text file with no file extension.

This behaviour is different to that experienced on the Windows version which does add the file extension by default.

Thanks

@ntoll
Copy link
Member

ntoll commented May 17, 2021

Aha... nice spot, I've just recreated the problem. Lemme work out a fix.

@ntoll
Copy link
Member

ntoll commented May 17, 2021

So, it appears that the results of calling QFileDialog.getSaveFileName are different between OSs. On Windows and Mac the system default file handler is used, and presumably works as expected given the following call (note the default file type filters). On Linux some other mechanism is used for for entering a new filename. I suspect, because of the inclusion of Other (*.*) in the filter, you can now save files without the expected .py extension (this was introduced so web mode could open CSS and HTML files).

path, _ = QFileDialog.getSaveFileName(
            self.widget,
            "Save file",
            folder if self.previous_folder is None else self.previous_folder,
            "Python (*.py);;Other (*.*)",
            "Python (*.py)",
        )

I'll add a fix into the view method that calls the file dialog, to ensure a .py is added to the end of a file that doesn't already have a file extension.

@ntoll
Copy link
Member

ntoll commented May 17, 2021

@amos1969 the fix is in this PR and should be in the next release once it's reviewed and checked.

@carlosperate carlosperate added this to the 1.1.0-beta.5 milestone May 17, 2021
@amos1969
Copy link
Contributor Author

Just checked it out and it worked exactly as expected, for me.

Thanks
Dave

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

Successfully merging a pull request may close this issue.

3 participants