Skip to content

register IPython's eventloop integration in plt.install_repl_displayhook #6734

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 1 commit into from
Jul 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def install_repl_displayhook():
Install a repl display hook so that any stale figure are automatically
redrawn when control is returned to the repl.

This works with both IPython terminals and vanilla python shells.
This works with IPython terminals and kernels,
as well as vanilla python shells.
"""
global _IP_REGISTERED
global _INSTALL_FIG_OBSERVER
Expand Down Expand Up @@ -154,6 +155,13 @@ def post_execute():

_IP_REGISTERED = post_execute
_INSTALL_FIG_OBSERVER = False

# trigger IPython's eventloop integration, if available
from IPython.core.pylabtools import backend2gui

ipython_gui_name = backend2gui.get(get_backend())
Copy link
Member

Choose a reason for hiding this comment

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

What does this do with backends that ipython can not map to a name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing. Since it's a get from a dict, gui_name will be None and it will take no further action, which can be interpreted as either:

  1. IPython doesn't know how to integrate with the eventloop for the given backend, or
  2. it doesn't need to (e.g. Agg)

Copy link
Member

Choose a reason for hiding this comment

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

🐑 right. Thought that backend2gui.get was something much more complicated.

if ipython_gui_name:
ip.enable_gui(ipython_gui_name)
else:
_INSTALL_FIG_OBSERVER = True

Expand Down