Skip to content

Commit 36f2259

Browse files
committed
Merge from 3.x. PR #4541
2 parents dd38512 + 1c8c168 commit 36f2259

File tree

6 files changed

+33
-115
lines changed

6 files changed

+33
-115
lines changed

Diff for: spyder/app/mainwindow.py

+8-37
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
from spyder.config.utils import IMPORT_EXT, is_gtk_desktop
144144
from spyder.app.cli_options import get_options
145145
from spyder import dependencies
146-
from spyder.config.ipython import QTCONSOLE_INSTALLED
147146
from spyder.py3compat import (getcwd, is_text_string, to_text_string,
148147
PY3, qbytearray_to_str, configparser as cp)
149148
from spyder.utils import encoding, programs
@@ -477,11 +476,6 @@ def signal_handler(signum, frame=None):
477476
# the window is in fullscreen mode:
478477
self.maximized_flag = None
479478

480-
# Track which console plugin type had last focus
481-
# True: Console plugin
482-
# False: IPython console plugin
483-
self.last_console_plugin_focus_was_python = True
484-
485479
# To keep track of the last focused widget
486480
self.last_focused_widget = None
487481
self.previous_focused_widget = None
@@ -882,11 +876,10 @@ def create_edit_action(text, tr_text, icon):
882876
self.variableexplorer.register_plugin()
883877

884878
# IPython console
885-
if QTCONSOLE_INSTALLED:
886-
self.set_splash(_("Loading IPython console..."))
887-
from spyder.plugins.ipythonconsole import IPythonConsole
888-
self.ipyconsole = IPythonConsole(self)
889-
self.ipyconsole.register_plugin()
879+
self.set_splash(_("Loading IPython console..."))
880+
from spyder.plugins.ipythonconsole import IPythonConsole
881+
self.ipyconsole = IPythonConsole(self)
882+
self.ipyconsole.register_plugin()
890883

891884
# Third-party plugins
892885
self.set_splash(_("Loading third-party plugins..."))
@@ -986,7 +979,7 @@ def trigger(i=i, self=self): # closure needed!
986979
programs.start_file(get_python_doc_path()))
987980
self.help_menu_actions.append(pydoc_act)
988981
# IPython documentation
989-
if self.ipyconsole is not None and self.help is not None:
982+
if self.help is not None:
990983
ipython_menu = QMenu(_("IPython documentation"), self)
991984
intro_action = create_action(self, _("Intro to IPython"),
992985
triggered=self.ipyconsole.show_intro)
@@ -1217,16 +1210,9 @@ def post_visible_setup(self):
12171210
self.console.dockwidget.hide()
12181211

12191212
# Show Help and Consoles by default
1220-
plugins_to_show = []
1213+
plugins_to_show = [self.ipyconsole]
12211214
if self.help is not None:
12221215
plugins_to_show.append(self.help)
1223-
if self.ipyconsole is not None:
1224-
if self.ipyconsole.isvisible:
1225-
plugins_to_show += [self.extconsole, self.ipyconsole]
1226-
else:
1227-
plugins_to_show += [self.ipyconsole, self.extconsole]
1228-
else:
1229-
plugins_to_show += [self.extconsole]
12301216
for plugin in plugins_to_show:
12311217
if plugin.dockwidget.isVisible():
12321218
plugin.dockwidget.raise_()
@@ -1236,8 +1222,7 @@ def post_visible_setup(self):
12361222
self.extconsole.toggle_view_action.setChecked(False)
12371223

12381224
# Show history file if no console is visible
1239-
ipy_visible = self.ipyconsole is not None and self.ipyconsole.isvisible
1240-
if not self.extconsole.isvisible and not ipy_visible:
1225+
if not self.ipyconsole.isvisible:
12411226
self.historylog.add_history(get_conf_path('history.py'))
12421227

12431228
if self.open_project:
@@ -1948,16 +1933,6 @@ def plugin_focus_changed(self):
19481933
self.update_edit_menu()
19491934
self.update_search_menu()
19501935

1951-
# Now deal with Python shell and IPython plugins
1952-
if self.ipyconsole is not None:
1953-
focus_client = self.ipyconsole.get_focus_client()
1954-
if focus_client is not None:
1955-
self.last_console_plugin_focus_was_python = False
1956-
else:
1957-
shell = get_focus_python_shell()
1958-
if shell is not None:
1959-
self.last_console_plugin_focus_was_python = True
1960-
19611936
def show_shortcuts(self, menu):
19621937
"""Show action shortcuts in menu"""
19631938
for element in getattr(self, menu + '_menu_actions'):
@@ -2446,11 +2421,7 @@ def execute_in_external_console(self, lines, focus_to_editor):
24462421
Execute lines in external or IPython console and eventually set focus
24472422
to the editor
24482423
"""
2449-
console = self.extconsole
2450-
if self.ipyconsole is None or self.last_console_plugin_focus_was_python:
2451-
console = self.extconsole
2452-
else:
2453-
console = self.ipyconsole
2424+
console = self.ipyconsole
24542425
console.visibility_changed(True)
24552426
console.raise_()
24562427
console.execute_code(lines)

Diff for: spyder/config/ipython.py

-43
This file was deleted.

Diff for: spyder/plugins/editor.py

+15-22
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
QToolBar, QVBoxLayout, QWidget)
3030

3131
# Local imports
32+
from spyder import dependencies
3233
from spyder.config.base import _, get_conf_path, PYTEST
3334
from spyder.config.main import (CONF, RUN_CELL_SHORTCUT,
3435
RUN_CELL_AND_ADVANCE_SHORTCUT)
@@ -52,6 +53,12 @@
5253
RunConfigDialog, RunConfigOneDialog)
5354

5455

56+
# Dependencies
57+
NBCONVERT_REQVER = ">=4.0"
58+
dependencies.add("nbconvert", _("Manipulate Jupyter notebooks on the Editor"),
59+
required_version=NBCONVERT_REQVER)
60+
61+
5562
def _load_all_breakpoints():
5663
bp_dict = CONF.get('run', 'breakpoints', {})
5764
for filename in list(bp_dict.keys()):
@@ -2338,17 +2345,11 @@ def clear_breakpoint(self, filename, lineno):
23382345

23392346
def debug_command(self, command):
23402347
"""Debug actions"""
2341-
if self.main.ipyconsole is not None:
2342-
if self.main.last_console_plugin_focus_was_python:
2343-
self.main.extconsole.execute_code(command)
2344-
else:
2345-
self.main.ipyconsole.write_to_stdin(command)
2346-
focus_widget = self.main.ipyconsole.get_focus_widget()
2347-
if focus_widget:
2348-
focus_widget.setFocus()
2349-
else:
2350-
self.main.extconsole.execute_code(command)
2351-
2348+
self.main.ipyconsole.write_to_stdin(command)
2349+
focus_widget = self.main.ipyconsole.get_focus_widget()
2350+
if focus_widget:
2351+
focus_widget.setFocus()
2352+
23522353
#------ Run Python script
23532354
@Slot()
23542355
def edit_run_configurations(self):
@@ -2443,17 +2444,9 @@ def re_run_file(self):
24432444
python, python_args, current, systerm,
24442445
post_mortem, clear_namespace) = self.__last_ec_exec
24452446
if current:
2446-
if self.main.ipyconsole is not None:
2447-
if self.main.last_console_plugin_focus_was_python:
2448-
self.run_in_current_extconsole.emit(fname, wdir, args,
2449-
debug, post_mortem)
2450-
else:
2451-
self.run_in_current_ipyclient.emit(fname, wdir, args,
2452-
debug, post_mortem,
2453-
clear_namespace)
2454-
else:
2455-
self.run_in_current_extconsole.emit(fname, wdir, args, debug,
2456-
post_mortem)
2447+
self.run_in_current_ipyclient.emit(fname, wdir, args,
2448+
debug, post_mortem,
2449+
clear_namespace)
24572450
else:
24582451
self.main.open_external_console(fname, wdir, args, interact,
24592452
debug, python, python_args,

Diff for: spyder/plugins/help.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from spyder import dependencies
2424
from spyder.config.base import _, get_conf_path, get_module_source_path
2525
from spyder.config.fonts import DEFAULT_SMALL_DELTA
26-
from spyder.config.ipython import QTCONSOLE_INSTALLED
2726
from spyder.api.plugins import SpyderPluginWidget
2827
from spyder.api.preferences import PluginConfigPage
2928
from spyder.py3compat import get_meth_class_inst, to_text_string
@@ -124,7 +123,6 @@ def setup_page(self):
124123
editor_box.setToolTip(editor_tip)
125124
ipython_box = self.create_checkbox(_("IPython Console"),
126125
'connect/ipython_console')
127-
ipython_box.setEnabled(QTCONSOLE_INSTALLED)
128126

129127
connections_layout = QVBoxLayout()
130128
connections_layout.addWidget(connections_label)
@@ -540,8 +538,7 @@ def apply_plugin_settings(self, options):
540538

541539
# To make auto-connection changes take place instantly
542540
self.main.editor.apply_plugin_settings(options=[connect_n])
543-
if self.main.ipyconsole is not None:
544-
self.main.ipyconsole.apply_plugin_settings(options=[connect_n])
541+
self.main.ipyconsole.apply_plugin_settings(options=[connect_n])
545542

546543
#------ Public API (related to Help's source) -------------------------
547544
def source_is_console(self):
@@ -889,10 +886,9 @@ def get_shell(self):
889886
"""
890887
if not hasattr(self.shell, 'get_doc') or not self.shell.is_running():
891888
self.shell = None
892-
if self.main.ipyconsole is not None:
893-
shell = self.main.ipyconsole.get_current_shellwidget()
894-
if shell is not None and shell.kernel_client is not None:
895-
self.shell = shell
889+
shell = self.main.ipyconsole.get_current_shellwidget()
890+
if shell is not None and shell.kernel_client is not None:
891+
self.shell = shell
896892
if self.shell is None:
897893
self.shell = self.internal_shell
898894
return self.shell

Diff for: spyder/plugins/ipythonconsole.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,19 @@
6060
from spyder.widgets.tabs import Tabs
6161

6262

63+
# Dependencies
6364
SYMPY_REQVER = '>=0.7.3'
6465
dependencies.add("sympy", _("Symbolic mathematics in the IPython Console"),
6566
required_version=SYMPY_REQVER, optional=True)
6667

67-
6868
CYTHON_REQVER = '>=0.21'
6969
dependencies.add("cython", _("Run Cython files in the IPython Console"),
7070
required_version=CYTHON_REQVER, optional=True)
7171

72+
QTCONSOLE_REQVER = ">=4.2.0"
73+
dependencies.add("qtconsole", _("Integrate the IPython console"),
74+
required_version=QTCONSOLE_REQVER)
75+
7276

7377
#------------------------------------------------------------------------------
7478
# Existing kernels
@@ -740,8 +744,6 @@ def refresh_plugin(self):
740744
sw = client.shellwidget
741745
self.variableexplorer.set_shellwidget_from_id(id(sw))
742746
self.help.set_shell(sw)
743-
if not self.testing:
744-
self.main.last_console_plugin_focus_was_python = False
745747
self.sig_update_plugin_title.emit()
746748

747749
def get_plugin_actions(self):

Diff for: spyder/plugins/projects.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,7 @@ def show_explorer(self):
386386

387387
def restart_consoles(self):
388388
"""Restart consoles when closing, opening and switching projects"""
389-
if self.main.ipyconsole:
390-
self.main.ipyconsole.restart()
389+
self.main.ipyconsole.restart()
391390

392391
def is_valid_project(self, path):
393392
"""Check if a directory is a valid Spyder project"""

0 commit comments

Comments
 (0)