##// END OF EJS Templates
Remove debug print statements
Emilio Graff -
Show More
@@ -95,16 +95,13 b' def matplotlib_options(mpl):'
95 mpqt)
95 mpqt)
96
96
97 def get_options():
97 def get_options():
98 print(f'`get_options` called with {os.environ.get("QT_API", None)=}')
99 """Return a list of acceptable QT APIs, in decreasing order of preference."""
98 """Return a list of acceptable QT APIs, in decreasing order of preference."""
100 #already imported Qt somewhere. Use that
99 #already imported Qt somewhere. Use that
101 loaded = loaded_api()
100 loaded = loaded_api()
102 if loaded is not None:
101 if loaded is not None:
103 print(f"`QtCore` already imported: {loaded=}")
104 return [loaded]
102 return [loaded]
105
103
106 mpl = sys.modules.get("matplotlib", None)
104 mpl = sys.modules.get("matplotlib", None)
107 print(f"{mpl=}") # will be None of matplotlib has not yet been imported
108
105
109 if mpl is not None and tuple(mpl.__version__.split(".")) < ("1", "0", "2"):
106 if mpl is not None and tuple(mpl.__version__.split(".")) < ("1", "0", "2"):
110 # 1.0.1 only supports PyQt4 v1
107 # 1.0.1 only supports PyQt4 v1
@@ -126,12 +123,9 b' def get_options():'
126 raise RuntimeError("Invalid Qt API %r, valid values are: %r" %
123 raise RuntimeError("Invalid Qt API %r, valid values are: %r" %
127 (qt_api, ', '.join(_qt_apis)))
124 (qt_api, ', '.join(_qt_apis)))
128 else:
125 else:
129 print(f"{qt_api=}")
130 return [qt_api]
126 return [qt_api]
131
127
132
128
133 api_opts = get_options()
129 api_opts = get_options()
134 print(f"Importing `IPython.terminal.pt_inputhooks.qt` with {api_opts=}")
135 QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
130 QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
136 print(f"Loaded Qt with {QT_API=}")
137 enum_helper = enum_factory(QT_API, QtCore)
131 enum_helper = enum_factory(QT_API, QtCore)
@@ -711,14 +711,12 b' class TerminalInteractiveShell(InteractiveShell):'
711
711
712 active_eventloop = None
712 active_eventloop = None
713 def enable_gui(self, gui=None):
713 def enable_gui(self, gui=None):
714 print(f"Someone called `enable_gui` with {gui=}.")
715 if self._inputhook is not None and gui is not None:
714 if self._inputhook is not None and gui is not None:
716 raise RuntimeError("Shell already running a gui event loop.")
715 raise RuntimeError("Shell already running a gui event loop.")
717 if gui and (gui not in {"inline", "webagg"}):
716 if gui and (gui not in {"inline", "webagg"}):
718 # This hook runs with each cycle of the `prompt_toolkit`'s event loop.
717 # This hook runs with each cycle of the `prompt_toolkit`'s event loop.
719 self.active_eventloop, self._inputhook = get_inputhook_name_and_func(gui)
718 self.active_eventloop, self._inputhook = get_inputhook_name_and_func(gui)
720 else:
719 else:
721 print(f"Disconnecting event loop {self._inputhook=}")
722 self.active_eventloop = self._inputhook = None
720 self.active_eventloop = self._inputhook = None
723
721
724 # For prompt_toolkit 3.0. We have to create an asyncio event loop with
722 # For prompt_toolkit 3.0. We have to create an asyncio event loop with
@@ -129,7 +129,6 b' def set_qt_api(gui):'
129
129
130
130
131 def get_inputhook_name_and_func(gui):
131 def get_inputhook_name_and_func(gui):
132 print(f"`get_inputhook_name_and_func` called with {gui=}")
133 if gui in registered:
132 if gui in registered:
134 return gui, registered[gui]
133 return gui, registered[gui]
135
134
@@ -137,7 +136,6 b' def get_inputhook_name_and_func(gui):'
137 raise UnknownBackend(gui)
136 raise UnknownBackend(gui)
138
137
139 if gui in aliases:
138 if gui in aliases:
140 print("gui has an alias")
141 return get_inputhook_name_and_func(aliases[gui])
139 return get_inputhook_name_and_func(aliases[gui])
142
140
143 gui_mod = gui
141 gui_mod = gui
@@ -20,9 +20,6 b' def _reclaim_excepthook():'
20 sys.excepthook = shell.excepthook
20 sys.excepthook = shell.excepthook
21
21
22
22
23 announced = 0
24
25
26 def inputhook(context):
23 def inputhook(context):
27 global _appref
24 global _appref
28 app = QtCore.QCoreApplication.instance()
25 app = QtCore.QCoreApplication.instance()
@@ -59,14 +56,7 b' def inputhook(context):'
59 QtCore.QTimer.singleShot(0, _reclaim_excepthook)
56 QtCore.QTimer.singleShot(0, _reclaim_excepthook)
60
57
61 event_loop = QtCore.QEventLoop(app)
58 event_loop = QtCore.QEventLoop(app)
62 global announced
59
63 if announced == 0:
64 print(f"`inputhook` running Qt {QtCore.qVersion()} event loop.")
65 announced += 1
66 elif announced == 10:
67 announced = 0
68 else:
69 announced += 1
70 if sys.platform == 'win32':
60 if sys.platform == 'win32':
71 # The QSocketNotifier method doesn't appear to work on Windows.
61 # The QSocketNotifier method doesn't appear to work on Windows.
72 # Use polling instead.
62 # Use polling instead.
General Comments 0
You need to be logged in to leave comments. Login now