##// END OF EJS Templates
ENH: Don't show message when enable the current eventloop....
Matthias Bussonnier -
Show More
@@ -4,7 +4,7 b' import asyncio'
4 import os
4 import os
5 import sys
5 import sys
6 from warnings import warn
6 from warnings import warn
7 from typing import Union as UnionType
7 from typing import Union as UnionType, Optional
8
8
9 from IPython.core.async_helpers import get_asyncio_loop
9 from IPython.core.async_helpers import get_asyncio_loop
10 from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
10 from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
@@ -912,8 +912,9 b' class TerminalInteractiveShell(InteractiveShell):'
912 if self._inputhook is not None:
912 if self._inputhook is not None:
913 self._inputhook(context)
913 self._inputhook(context)
914
914
915 active_eventloop = None
915 active_eventloop: Optional[str] = None
916 def enable_gui(self, gui=None):
916
917 def enable_gui(self, gui: Optional[str] = None) -> None:
917 if self.simple_prompt is True and gui is not None:
918 if self.simple_prompt is True and gui is not None:
918 print(
919 print(
919 f'Cannot install event loop hook for "{gui}" when running with `--simple-prompt`.'
920 f'Cannot install event loop hook for "{gui}" when running with `--simple-prompt`.'
@@ -928,8 +929,15 b' class TerminalInteractiveShell(InteractiveShell):'
928 return
929 return
929
930
930 if self._inputhook is not None and gui is not None:
931 if self._inputhook is not None and gui is not None:
931 print(
932 newev, newinhook = get_inputhook_name_and_func(gui)
932 f"Shell is already running a gui event loop for {self.active_eventloop}. "
933 if self._inputhook == newinhook:
934 # same inputhook, do nothing
935 self.log.info(
936 f"Shell is already running the {self.active_eventloop} eventloop. Doing nothing"
937 )
938 return
939 self.log.warning(
940 f"Shell is already running a different gui event loop for {self.active_eventloop}. "
933 "Call with no arguments to disable the current loop."
941 "Call with no arguments to disable the current loop."
934 )
942 )
935 return
943 return
@@ -1,5 +1,6 b''
1 import importlib
1 import importlib
2 import os
2 import os
3 from typing import Tuple, Callable
3
4
4 aliases = {
5 aliases = {
5 'qt4': 'qt',
6 'qt4': 'qt',
@@ -119,7 +120,7 b' def set_qt_api(gui):'
119 return qt_env2gui[QT_API]
120 return qt_env2gui[QT_API]
120
121
121
122
122 def get_inputhook_name_and_func(gui):
123 def get_inputhook_name_and_func(gui: str) -> Tuple[str, Callable]:
123 if gui in registered:
124 if gui in registered:
124 return gui, registered[gui]
125 return gui, registered[gui]
125
126
General Comments 0
You need to be logged in to leave comments. Login now