From 5c57ffec50e1e86013a236f922ea9a53baec427e 2023-01-03 12:43:16 From: Emilio Graff <1@emil.io> Date: 2023-01-03 12:43:16 Subject: [PATCH] Don't allow switching gui without detatching --- diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py index 83c0bd7..5fd51e5 100644 --- a/IPython/terminal/interactiveshell.py +++ b/IPython/terminal/interactiveshell.py @@ -712,6 +712,8 @@ class TerminalInteractiveShell(InteractiveShell): active_eventloop = None def enable_gui(self, gui=None): print(f'Someone called `enable_gui` with {gui=}.') + if self._inputhook is not None and gui is not None: + raise RuntimeError("Shell already running a gui event loop.") if gui and (gui not in {"inline", "webagg"}): # This hook runs with each cycle of the `prompt_toolkit`'s event loop. self.active_eventloop, self._inputhook = get_inputhook_name_and_func(gui)