Skip to content

FIX: don't import macosx to check if eventloop running #12603

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

Merged
merged 2 commits into from
Oct 23, 2018

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Oct 23, 2018

PR Summary

Alternative to #12557

Crossref #11850,

@anntzer, isn't this right? If the user has started the macosx event loop, they must have already imported macosx?

OTOH I am not sure how to make a Mac GUI to test that this test now does the right thing if the user has made a GUI. If someone has a easy GUI to test, that'd help...

Framework build:

From python prompt:

import matplotlib.pyplot as plt

Goes to MacOSX backend, bounces dock icon, but keeps focus on terminal

import matplotlib; matplotlib.use('qt5agg'); import matplotlib.pyplot as plt

No icon until a draw command is given. (Goes to QT5)

non-Framework

import matplotlib.pyplot as plt

falls back to qt5AGG

import matplotlib; matplotlib.use('macosx'); import matplotlib.pyplot as plt

Gives import error.

So.... I think this all works as expected. The windows connection gets made earlier than we'd like ( NSApp = [NSApplication sharedApplication]; in verify_framework()), but there is no way around that.

This also no longer uses the deprecated code.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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

pass
else:
if _macosx.event_loop_is_running():
if ('_macosx' in sys.modules) and (_macosx.event_loop_is_running()):
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to get the module under the correct name ("matplotlib.backends._macosx" in sys.modules) and then fetch it out of sys.modules (sys.modules["matplotlib.backends._macosx"].event_loop_is_running()) (can be split over multiple lines as for the other modules above) but other than that, it looks like a reasonable solution.

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

Dunno whether it helps with the bouncing rocket but it can't hurt, and is consistent with the other checks.

@jklymak
Copy link
Member Author

jklymak commented Oct 23, 2018

The icon still bounces if you select or fallback to MacOSX. But at least it no longer always bounces, which is what it does in 3.0.0 for the framework pythons.

@tacaswell tacaswell added this to the v3.0.x milestone Oct 23, 2018
@tacaswell tacaswell merged commit d85811d into matplotlib:master Oct 23, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Oct 23, 2018
@jklymak jklymak deleted the fix-dont-import-macosx branch October 23, 2018 23:11
tacaswell added a commit that referenced this pull request Oct 23, 2018
…603-on-v3.0.x

Backport PR #12603 on branch v3.0.x (FIX: don't import macosx to check if eventloop running)
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.

3 participants