Show More
@@ -4,7 +4,7 b' import asyncio' | |||
|
4 | 4 | import os |
|
5 | 5 | import sys |
|
6 | 6 | from warnings import warn |
|
7 | from typing import Union as UnionType | |
|
7 | from typing import Union as UnionType, Optional | |
|
8 | 8 | |
|
9 | 9 | from IPython.core.async_helpers import get_asyncio_loop |
|
10 | 10 | from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC |
@@ -912,8 +912,9 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
912 | 912 | if self._inputhook is not None: |
|
913 | 913 | self._inputhook(context) |
|
914 | 914 | |
|
915 | active_eventloop = None | |
|
916 | def enable_gui(self, gui=None): | |
|
915 | active_eventloop: Optional[str] = None | |
|
916 | ||
|
917 | def enable_gui(self, gui: Optional[str] = None) -> None: | |
|
917 | 918 | if self.simple_prompt is True and gui is not None: |
|
918 | 919 | print( |
|
919 | 920 | f'Cannot install event loop hook for "{gui}" when running with `--simple-prompt`.' |
@@ -928,8 +929,15 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
928 | 929 | return |
|
929 | 930 | |
|
930 | 931 | if self._inputhook is not None and gui is not None: |
|
931 | print( | |
|
932 | f"Shell is already running a gui event loop for {self.active_eventloop}. " | |
|
932 | newev, newinhook = get_inputhook_name_and_func(gui) | |
|
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 | 941 | "Call with no arguments to disable the current loop." |
|
934 | 942 | ) |
|
935 | 943 | return |
@@ -1,5 +1,6 b'' | |||
|
1 | 1 | import importlib |
|
2 | 2 | import os |
|
3 | from typing import Tuple, Callable | |
|
3 | 4 | |
|
4 | 5 | aliases = { |
|
5 | 6 | 'qt4': 'qt', |
@@ -119,7 +120,7 b' def set_qt_api(gui):' | |||
|
119 | 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 | 124 | if gui in registered: |
|
124 | 125 | return gui, registered[gui] |
|
125 | 126 |
General Comments 0
You need to be logged in to leave comments.
Login now