ENH: by-pass creating a local class if backend has a Backend class#22380
ENH: by-pass creating a local class if backend has a Backend class#22380tacaswell wants to merge 1 commit intomatplotlib:mainfrom
Conversation
|
I guess we need to standardize on a name there, effectively saying "a module with a Foo global is a backend". I'm fine with calling that Backend, I just want to make sure we agree on the name. OTOH, another approach (#18854) would be to move "everything" to the FigureCanvas class ("a module with a FigureCanvas global is a backend"). (Note, in particular, that this allows reusing the already preexisting inheritance relationship that exists between canvases.) Perhaps you can comment on that PR? |
|
I like #18854 a lot better. It gives you a path to from just a Figure walk your way up to building it a sibling in whatever scheme of canvas / manager / show / etc the user has put together. I had thought about attaching the Backend object to Thinking a bit more about the toolbar discussion, I think having down-stream sub-class either the Manger or Toolbar classes is not a terrible pattern to suggest. We tend to think in terms of libraries and compos-ability (which makes sense given our interest in working at the library level!), but the cases where I have seen where there is significant toolbar customization have been domain specific applications (the buttons the added only made sense in a very narrow science context) where the lack of being able to compose with another packages modifications does not matter. Closing in favor of #18854 where (as normal) @anntzer is a few steps ahead of me. |
PR Summary
Simplify using a backend that has a backend class. I think this is the next step down the path @anntzer started us on.
There is analogous code in mpl-gui at https://github.com/tacaswell/mpl-gui/blob/bc0cdc7bd58095039f124516cd6ca88611509513/mpl_gui/_manage_backend.py#L87-L109 .
It may be worth holding this PR until we sort out if there is anything else we want to hoist upstream from mpl_gui.
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).This is implicitly tested, but might be worth pushing in some explicit tests of when the local backend does or does not get created.
Documentation
doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).