Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix wx canvas type injection.#10428

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DietmarSchwertberger merged 1 commit intomatplotlib:masterfromanntzer:wxcanvas
Feb 24, 2018

Conversation

anntzer
Copy link
Contributor

NavigationToolbar2Wx should usetype(self.canvas) when instantiating
the canvas to make it work with all of wx, wxagg, wxcairo (instantiating
the corresponding canvas class in each case). Conversely, FigureFrameWx
should explicitly use FigureCanvasWx; other backends (wxagg, wxcairo)
override the method accordingly.

I got these inverted in my previous PR and this breaks the wx backend.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

NavigationToolbar2Wx should use `type(self.canvas)` when instantiatingthe canvas to make it work with all of wx, wxagg, wxcairo (instantiatingthe corresponding canvas class in each case).  Conversely, FigureFrameWxshould explicitly use FigureCanvasWx; other backends (wxagg, wxcairo)override the method accordingly.I got these inverted in my previous PR and this breaks the wx backend.
@anntzeranntzer added Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. GUI: wx labelsFeb 12, 2018
@anntzeranntzer added this to thev2.2 milestoneFeb 12, 2018
@tacaswelltacaswell modified the milestones:v2.2,v2.2.0Feb 12, 2018
@DietmarSchwertberger
Copy link
Contributor

At the moment theNavigationToolbars for wx are broken and inconsistent and this PR would not fully fix things.

As you wrote, in 'master'backend_wx.NavigationToolbar2Wx uses this:

    def get_canvas(self, frame, fig):        return FigureCanvasWx(frame, -1, fig)

Inbackend_wxagg.py theNavigationToolbar2WxAgg is derived and marked deprecated:

@cbook.deprecated("2.2")class NavigationToolbar2WxAgg(NavigationToolbar2Wx):    def get_canvas(self, frame, fig):        return FigureCanvasWxAgg(frame, -1, fig)

What is missing here is an assignment toToolbar and this breaks e.g.embedding_in_wx3_sgskip.py

Toolbar = NavigationToolbar2WxAgg

Inbackend_wxcairo.py theNavigationToolbar2Wx is imported.
The assignment forToolbar is missing.get_canvas is broken and would be fixed by the PR.

So the options are:

  • have a singleNavigationToolbar2Wx inbackend_wx withget_canvas asreturn type(self.canvas)(self, -1, fig); import it to the other backends and assign it toToolbar
  • have derived classes inbackend_wxagg andbackend_wxcairo; both assigned toToolbar as well

I don't have a strong preference for either of the options, but a small preference for the derived classes as I prefer explicit over implicit. If you prefer the singleNavigationToolbar2Wx, I'm fine with this as well.

What is the situation about deprecating theNavigationToolbars? If they are deprecated, it should be consistent.
The derived classes have the advantage that the deprecation messages are a bit clearer.

@anntzer
Copy link
ContributorAuthor

Removal of the Toolbar alias came in in#9938 and I would support either keeping it out (and fixing the example), or, if we want to have it back, it should be present for all backends (as a "standard backend interface").

I would prefer keeping a single class to make it easier to write renderer-independent code. (And yes, having a single alias for Toolbar would also help that purpose, but again in that case it seems preferable to let all relevant backends have it.)

@DietmarSchwertberger
Copy link
Contributor

For 3.0 the Toolbar alias certainly should be removed.
For 2.2 the examples should be updated not to use it, as the 'reference' example does not have it:https://matplotlib.org/users/navigation_toolbar.html
For the alias in 2.2 I'm not sure. I would count the removal as API change.

I've seen that theget_canvas method is just used for the subplot configuration, so I'm fine with the single class. I don't like the subplot configuration as it is as it does not match the GUI look and feel.
For the tool manager version that is to be done, I would prefer a real wx implementation, i.e. with wx sliders.

TheSubplotToolWX class seems to be unused. Right?

@anntzer
Copy link
ContributorAuthor

I agree strongly with you that native widgets should be preferred (see e.g.#8683), but see also#7696 for arguments against it.

Can you fix the examples in a separate PR (or list the examples that need to be fixed)?

SubplotToolWx seems to essentially be a copy of the body of configure_subplots. I'm fine with deprecating it or making it private (in general I think all these are backend implementation details...).

@DietmarSchwertberger
Copy link
Contributor

I've just submitted PR 10518 to fix the inconsistencies. With this, 10518 and 10429 we're probably done for 2.2.
Thanks a lot.

Regarding native vs. Matplotlib widgets: I think for Subplot it would make sense to implement it in Matplotlib, but not as separate window. The best would be to have the plot borders draggable...

@DietmarSchwertbergerDietmarSchwertberger mentioned this pull requestFeb 20, 2018
6 tasks
@DietmarSchwertbergerDietmarSchwertberger merged commit149ee00 intomatplotlib:masterFeb 24, 2018
tacaswell added a commit that referenced this pull requestFeb 24, 2018
@anntzeranntzer deleted the wxcanvas branchFebruary 24, 2018 20:31
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DietmarSchwertbergerDietmarSchwertbergerDietmarSchwertberger approved these changes

Assignees
No one assigned
Labels
GUI: wxRelease criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v2.2.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@DietmarSchwertberger@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp