Skip to content

Conversation

@greglucas
Copy link
Contributor

PR Summary

This adds the rcParams savefig.directory option into the macosx
backend for the savefig dialog window.

Additionally cleans up some of the UTF8 string allocations in this code block.

Closes #21710

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@greglucas greglucas added this to the v3.6.0 milestone Jan 10, 2022
self.canvas.remove_rubberband()

def save_figure(self, *args):
directory = os.path.expanduser(mpl.rcParams['savefig.directory'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a smoke test for this in the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I think this is another PR that would be quite hard to add a test for because it is using the GUI :( I did a global search and didn't see any of the other backends testing this either...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that back, I just pushed up a test to hijack the GUI function and return a well-defined string instead. I think that should get codecov for the Python branches at least... Still not testing the Objective-C updates, but better than nothing?

@greglucas greglucas force-pushed the macosx-savefig branch 2 times, most recently from 647451d to bd7d627 Compare January 10, 2022 16:25
@greglucas greglucas requested a review from dstansby March 5, 2022 18:17
This adds the rcParams savefig.directory option into the macosx
backend for the savefig dialog window.
@greglucas
Copy link
Contributor Author

Ping for a review from any mac users that want to test this out.

@greglucas
Copy link
Contributor Author

@dstansby / mac users, reminder for another review on this one as well.

  • You should be able to set the savefig directory with rcParams now
  • The previously saved directory should be the default directory upon a second save figure request. (Save to /tmp the first time, and then the next time it should bring up /tmp as the default save location)

@jklymak jklymak merged commit dd001ed into matplotlib:main May 18, 2022
@QuLogic QuLogic mentioned this pull request Sep 9, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH]: macosx backend does not respect rcParams["savefig.directory"]

5 participants