-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use user-selected format in Tk savefig, rather than inferring it from the filename #24531
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
Conversation
I tried to test this locally, but that lead me to discovering that this dialog in broken on Fedora 37 with py311 with tk 8.6.12 with wayland both on this branch and 3.6.2 and with the system Python + building from the py311 branch. I have not chased down which of those is the source of the problem (but if I had to guess I would say wayland....) This may catch out some people who type in the extension they want without changing the selector? Is that actually true and if so, do we think that is going to be a common problem? We probably should mention it as a behavior change? |
I don't see any such problem with RPM Matplotlib or |
I hadn't considered that - I copied the behaviour from the GTK backend, which uses the selected format, but it looks like macosx and Qt ignore the selected format and just use the filename, and wx uses the selected format but warns if it differs from the filename. I'm not sure which behaviour is most intuitive - even on default Windows programs, turns out mspaint uses the selected format, while wordpad uses the filename. |
by |
OK, I can reproduce in |
Wx warning is my favorite behavior (it tells the user they are doing something ambiguous and we have taken a guess at what they meant), all of the backends should probably do that. As for which way it breaks:
As for which way makes more sense:
|
FWIW I much prefer following whatever the user typed (which is qt's behavior); as an example, inkscape forces you (or at least used to, haven't checked recently) to go through the combobox which I find supremely annoying (especially when there are many, many formats supported and you need to figure out where is the one you want). |
I pushed this to 3.8 because we need to sort out which of the 3 behaviors is "right". |
Having spoken to some others and looked at how different software behaves, I now also think it's best to have the typed extension take priority over the dropdown, so keeping the existing behaviour. I've updated the PR, so now it only uses the dropdown selection if the filename contains no extension, and also correctly sorts the extensions in alphabetical order. |
ping @anntzer @tacaswell for new behaviour change. |
<optional_dependencies>` are being bumped: | ||
|
||
+------------+-----------------+---------------+ | ||
| Dependency | min in mpl3.6 | min in mpl3.7 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Dependency | min in mpl3.6 | min in mpl3.7 | | |
| Dependency | min in mpl3.7 | min in mpl3.8 | |
👍🏻 to this change, but I think it needs a behavior change note. |
Ditto, the new behavior looks good to me. |
@daniilS can you handle the behaviour change? Otherwise this looks good to go... |
2d9ff14
to
6b28bef
Compare
@jklymak apologies for the delay, behaviour change note added & api note updated to 3.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A rebase should fix the documentation build.
Also, the default file name includes .png
, which means you can't simply change the type and get a different type, as the filename overrides. If would be nice if (extension of text == old filetype) then the extension were changed to the new type. Or perhaps the extension could just not be added.
Co-Authored-By: Elliott Sales de Andrade <quantum.analyst@gmail.com>
11b1854
to
b876de8
Compare
Good point - Windows (and I think MacOS, but not sure) automatically edits the filename when changing the dropdown selection, but the Tk implementation of the dialog on Linux does not. Not giving an extension by default seems like the best solution to me. |
PR Summary
This also allows us to sort all extensions in alphabetical order, in line with the other backends, rather than having to put the default option first.
This change required raising the minimum supported version of Tk to 8.5, as discussed in #24450. I also removed a try statement around
iconphoto
, which should only have failed on Tk < 8.5 - it didn't feel big enough to deserve its own PR, but happy to separate it out if anyone disagrees.Closes #24450.
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst