Skip to content

Commit

Permalink
Python Console: Reduce the number of supported backends
Browse files Browse the repository at this point in the history
Fixes #2471
Fixes #2348

- From now on we will only support Qt, Tk and MacOSX backends. I really
don't know how to support the other ones (i.e. Gtk and Wx), so I'm
removing support to set them in the interface.
  • Loading branch information
ccordoba12 committed Jul 12, 2015
1 parent 20ae4b1 commit 1cf9ef6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
7 changes: 2 additions & 5 deletions spyderlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,7 @@ def is_ubuntu():
'qt/api': 'default',
'pyqt/api_version': 2,
'pyqt/ignore_sip_setapi_errors': False,
'matplotlib/backend/enabled': True,
'matplotlib/backend/value': 'MacOSX' if (sys.platform == 'darwin' \
and os.environ.get('QT_API') == 'pyside')\
else 'Qt4Agg',
'matplotlib/backend/value': 0,
'umr/enabled': True,
'umr/verbose': True,
'umr/namelist': ['guidata', 'guiqwt'],
Expand Down Expand Up @@ -745,7 +742,7 @@ def is_ubuntu():
# 2. If you want to *remove* options that are no longer needed in our codebase,
# you need to do a MAJOR update in version, e.g. from 3.0.0 to 4.0.0
# 3. You don't need to touch this value if you're just adding a new option
CONF_VERSION = '18.1.0'
CONF_VERSION = '19.0.0'

# XXX: Previously we had load=(not DEV) here but DEV was set to *False*.
# Check if it *really* needs to be updated or not
Expand Down
49 changes: 27 additions & 22 deletions spyderlib/plugins/externalconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,29 +318,37 @@ def setup_page(self):
pyqt_layout.addWidget(ignore_api_box)
pyqt_group.setLayout(pyqt_layout)
qt_layout.addWidget(pyqt_group)

# Matplotlib Group
mpl_group = QGroupBox(_("Matplotlib"))
mpl_backend_box = newcb('', 'matplotlib/backend/enabled', True)
mpl_backend_edit = self.create_lineedit(_("GUI backend:"),
'matplotlib/backend/value',
tip=_("Set the GUI toolkit used by <br>"
"Matplotlib to show figures "
"(default: Qt4Agg)"),
alignment=Qt.Horizontal)
mpl_backend_box.toggled.connect(mpl_backend_edit.setEnabled)
mpl_backend_layout = QHBoxLayout()
mpl_backend_layout.addWidget(mpl_backend_box)
mpl_backend_layout.addWidget(mpl_backend_edit)
mpl_backend_edit.setEnabled(
self.get_option('matplotlib/backend/enabled'))
mpl_group = QGroupBox(_("Graphics"))
mpl_label = QLabel(_("Decide which backend to use to display graphics. "
"If unsure, please select the <b>Qt</b> "
"backend.<br><br>"
"<b>Note:</b> We support a very limited amount "
"of backends in our Python consoles. If you "
"prefer to work with a different one, please use "
"an IPython console."))
mpl_label.setWordWrap(True)

backends = [("Qt", 0)]
if programs.is_module_installed('_tkinter'):
backends.append( ("Tkinter", 1) )
if sys.platform == 'darwin':
backends.append( ("Mac OSX", 2) )
backends = tuple(backends)

mpl_backend_box = self.create_combobox( _("Backend:")+" ", backends,
'matplotlib/backend/value',
tip=_("This option will be applied the "
"next time a console is opened."))

mpl_installed = programs.is_module_installed('matplotlib')

mpl_layout = QVBoxLayout()
mpl_layout.addLayout(mpl_backend_layout)
mpl_layout.addWidget(mpl_label)
mpl_layout.addWidget(mpl_backend_box)
mpl_group.setLayout(mpl_layout)
mpl_group.setEnabled(mpl_installed)

# ETS Group
ets_group = QGroupBox(_("Enthought Tool Suite"))
ets_label = QLabel(_("Enthought Tool Suite (ETS) supports "
Expand Down Expand Up @@ -786,10 +794,7 @@ def start(self, fname, wdir=None, args='', interact=False, debug=False,
else:
pythonstartup = self.get_option('pythonstartup', None)
monitor_enabled = self.get_option('monitor/enabled')
if self.get_option('matplotlib/backend/enabled'):
mpl_backend = self.get_option('matplotlib/backend/value')
else:
mpl_backend = None
mpl_backend = self.get_option('matplotlib/backend/value')
ets_backend = self.get_option('ets_backend')
qt_api = self.get_option('qt/api')
if qt_api not in ('pyqt', 'pyside'):
Expand Down
5 changes: 3 additions & 2 deletions spyderlib/widgets/externalshell/pythonshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,9 @@ def create_process(self):

# External modules options
env.append('ETS_TOOLKIT=%s' % self.ets_backend)
if self.mpl_backend:
env.append('MATPLOTLIB_BACKEND=%s' % self.mpl_backend)
if self.mpl_backend is not None:
backends = {0: 'Qt4Agg', 1: 'TkAgg', 2: 'MacOSX'}
env.append('MATPLOTLIB_BACKEND=%s' % backends[self.mpl_backend])
if self.qt_api:
env.append('QT_API=%s' % self.qt_api)
env.append('COLORIZE_SYS_STDERR=%s' % self.colorize_sys_stderr)
Expand Down
4 changes: 2 additions & 2 deletions spyderlib/widgets/externalshell/sitecustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,9 @@ def __init__(self, namelist=None, pathlist=None):
if namelist is None:
namelist = []
spy_modules = ['sitecustomize', 'spyderlib', 'spyderplugins']
mpl_modules = ['matplotlib', 'tkinter', 'Tkinter', 'gtk']
mpl_modules = ['matplotlib', 'tkinter', 'Tkinter']
self.namelist = namelist + spy_modules + mpl_modules

if pathlist is None:
pathlist = []
self.pathlist = pathlist
Expand Down

0 comments on commit 1cf9ef6

Please sign in to comment.