MCPcopy Index your code
hub / github.com/ipython/ipython / enable_gui

Method enable_gui

IPython/terminal/interactiveshell.py:1060–1107  ·  view source on GitHub ↗
(self, gui: Optional[str] = None)

Source from the content-addressed store, hash-verified

1058 active_eventloop: Optional[str] = None
1059
1060 def enable_gui(self, gui: Optional[str] = None) -> None:
1061 if gui:
1062 from ..core.pylabtools import _convert_gui_from_matplotlib
1063
1064 gui = _convert_gui_from_matplotlib(gui)
1065
1066 if self.simple_prompt is True and gui is not None:
1067 if gui == "tk":
1068 print(
1069 "Tk is supported natively when running with `--simple-prompt`; "
1070 "no event loop hook will be installed."
1071 )
1072 else:
1073 print(
1074 f'Cannot install event loop hook for "{gui}" when running with `--simple-prompt`.'
1075 )
1076 print(
1077 "NOTE: Tk is supported natively; use Tk apps and Tk backends with `--simple-prompt`."
1078 )
1079 return
1080
1081 if self._inputhook is None and gui is None:
1082 print("No event loop hook running.")
1083 return
1084
1085 if self._inputhook is not None and gui is not None:
1086 newev, newinhook = get_inputhook_name_and_func(gui)
1087 if self._inputhook == newinhook:
1088 # same inputhook, do nothing
1089 self.log.info(
1090 f"Shell is already running the {self.active_eventloop} eventloop. Doing nothing"
1091 )
1092 return
1093 self.log.warning(
1094 f"Shell is already running a different gui event loop for {self.active_eventloop}. "
1095 "Call with no arguments to disable the current loop."
1096 )
1097 return
1098 if self._inputhook is not None and gui is None:
1099 self.active_eventloop = self._inputhook = None
1100
1101 if gui and (gui not in {None, "webagg"}):
1102 # This hook runs with each cycle of the `prompt_toolkit`'s event loop.
1103 self.active_eventloop, self._inputhook = get_inputhook_name_and_func(gui)
1104 else:
1105 self.active_eventloop = self._inputhook = None
1106
1107 self._use_asyncio_inputhook = gui == "asyncio"
1108
1109 # Run !system commands directly, not through pipes, so terminal programs
1110 # work correctly.

Callers

nothing calls this directly

Calls 3

infoMethod · 0.80

Tested by

no test coverage detected