Skip to content

Commit 4a4ada8

Browse files
committed
IPython console: Correctly set Automatic and Qt Matplotlib backends when using PyQt5
Fixes #2792
1 parent d3d92a7 commit 4a4ada8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Diff for: spyderlib/widgets/externalshell/start_ipython_kernel.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def sympy_config(mpl_backend):
3838

3939
def kernel_config():
4040
"""Create a config object with IPython kernel options"""
41+
import os
42+
4143
from IPython.config.loader import Config, load_pyconfig_files
4244
from IPython.core.application import get_ipython_dir
4345
from spyderlib.config.main import CONF
@@ -69,13 +71,23 @@ def kernel_config():
6971
mpl_backend = None
7072
mpl_installed = is_module_installed('matplotlib')
7173
pylab_o = CONF.get('ipython_console', 'pylab')
74+
external_interpreter = \
75+
os.environ.get('EXTERNAL_INTERPRETER', '').lower() == "true"
7276

7377
if mpl_installed and pylab_o:
7478
# Get matplotlib backend
75-
backend_o = CONF.get('ipython_console', 'pylab/backend', 0)
76-
backends = {0: 'inline', 1: 'auto', 2: 'qt', 3: 'osx', 4: 'gtk',
77-
5: 'wx', 6: 'tk'}
78-
mpl_backend = backends[backend_o]
79+
if not external_interpreter:
80+
if os.environ["QT_API"] == 'pyqt5':
81+
qt_backend = 'qt5'
82+
else:
83+
qt_backend = 'qt'
84+
85+
backend_o = CONF.get('ipython_console', 'pylab/backend', 0)
86+
backends = {0: 'inline', 1: qt_backend, 2: qt_backend, 3: 'osx',
87+
4: 'gtk', 5: 'wx', 6: 'tk'}
88+
mpl_backend = backends[backend_o]
89+
else:
90+
mpl_backend = 'inline'
7991

8092
# Automatically load Pylab and Numpy, or only set Matplotlib
8193
# backend

0 commit comments

Comments
 (0)