Repository navigation
support %matplotlib qt5 and %matplotlib nbagg - #6587
Merged
Merged
Conversation
same as terminal IPython in ipython#6496 didn't need anything beyond register
just needed the key, since `%gui qt5` already works
Contributor
|
Can you also add support for nbagg? |
we don't need to do anything, just add keys to a couple of dictionaries
%matplotlib qt5%matplotlib qt5 and %matplotlib nbagg
Member
Author
|
Yup, since we don't need to do anything for nbagg support, I just added the relevant keys where needed. I will do a separate PR not to be backported, where I will propose |
takluyver
added a commit
that referenced
this pull request
Oct 1, 2014
support `%matplotlib qt5` and `%matplotlib nbagg`
takluyver
added a commit
that referenced
this pull request
Oct 1, 2014
Contributor
|
Awesome! I just got to testing this and am getting strange behavior. The first time I run (py3k)tcaswell@eowyn:~$ ipython
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
Type "copyright", "credits" or "license" for more information.
IPython 3.0.0-dev -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: %matplotlib qt5
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-fbf5de2c563c> in <module>()
----> 1 get_ipython().magic('matplotlib qt5')
/home/tcaswell/other_source/ipython/IPython/core/interactiveshell.py in magic(self, arg_s)
2275 magic_name, _, magic_arg_s = arg_s.partition(' ')
2276 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2277 return self.run_line_magic(magic_name, magic_arg_s)
2278
2279 #-------------------------------------------------------------------------
/home/tcaswell/other_source/ipython/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
2196 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2197 with self.builtin_trap:
-> 2198 result = fn(*args,**kwargs)
2199 return result
2200
/home/tcaswell/other_source/ipython/IPython/core/magics/pylab.py in matplotlib(self, line)
/home/tcaswell/other_source/ipython/IPython/core/magic.py in <lambda>(f, *a, **k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, *a, **k: f(*a, **k)
194
195 if callable(arg):
/home/tcaswell/other_source/ipython/IPython/core/magics/pylab.py in matplotlib(self, line)
78 """
79 args = magic_arguments.parse_argstring(self.matplotlib, line)
---> 80 gui, backend = self.shell.enable_matplotlib(args.gui)
81 self._show_matplotlib_backend(args.gui, backend)
82
/home/tcaswell/other_source/ipython/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
3009 # Now we must activate the gui pylab wants to use, and fix %run to take
3010 # plot updates into account
-> 3011 self.enable_gui(gui)
3012 self.magics_manager.registry['ExecutionMagics'].default_runner = \
3013 pt.mpl_runner(self.safe_execfile)
/home/tcaswell/other_source/ipython/IPython/terminal/interactiveshell.py in enable_gui(gui, app)
307 from IPython.lib.inputhook import enable_gui as real_enable_gui
308 try:
--> 309 return real_enable_gui(gui, app)
310 except ValueError as e:
311 raise UsageError("%s" % e)
/home/tcaswell/other_source/ipython/IPython/lib/inputhook.py in enable_gui(self, gui, app)
248 self._current_gui = gui
249
--> 250 app = gui_hook.enable(app)
251 if app is not None:
252 app._in_event_loop = True
/home/tcaswell/other_source/ipython/IPython/lib/inputhook.py in enable(self, app)
383 def enable(self, app=None):
384 os.environ['QT_API'] = 'pyqt5'
--> 385 return Qt4InputHook.enable(self, app)
386
387
/home/tcaswell/other_source/ipython/IPython/lib/inputhook.py in enable(self, app)
362 app = QtGui.QApplication(sys.argv)
363 """
--> 364 from IPython.lib.inputhookqt4 import create_inputhook_qt4
365 from IPython.external.appnope import nope
366 app, inputhook_qt4 = create_inputhook_qt4(self, app)
/home/tcaswell/other_source/ipython/IPython/lib/inputhookqt4.py in <module>()
22
23 from IPython.core.interactiveshell import InteractiveShell
---> 24 from IPython.external.qt_for_kernel import QtCore, QtGui
25 from IPython.lib.inputhook import allow_CTRL_C, ignore_CTRL_C, stdin_ready
26
/home/tcaswell/other_source/ipython/IPython/external/qt_for_kernel.py in <module>()
78 api_opts = get_options()
79 if api_opts is not None:
---> 80 QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
81
82 else: # use ETS variable
/home/tcaswell/other_source/ipython/IPython/external/qt_loaders.py in load_qt(api_options)
294 has_binding(QT_API_PYQT5),
295 has_binding(QT_API_PYSIDE),
--> 296 api_options))
ImportError:
Could not load requested Qt binding. Please ensure that
PyQt4 >= 4.7, PyQt5 or PySide >= 1.0.3 is available,
and only one is imported per session.
Currently-imported Qt library: 'pyqt5'
PyQt4 installed: True
PyQt5 installed: False
PySide >= 1.0.3 installed: True
Tried to load: ['pyqt5']
In [2]: %matplotlib qt5
In [3]: It works as expected before the second call to the magic, but the error is disconcerting (particularly because |
mattvonrocketstein
pushed a commit
to mattvonrocketstein/ipython
that referenced
this pull request
Nov 3, 2014
support `%matplotlib qt5` and `%matplotlib nbagg`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
just needed the key, since
%gui qt5already worksalso copy
%gui qt5logic from #6496 to the kernel eventloop registry.closes #6057