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