From 93278ade075ca4b6483afac10f9a2d1e775a5f36 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 8 Sep 2026 23:54:10 -0400 Subject: [PATCH] Backport PR #32321: DOC: correct note about PyOS_InputHook --- .../figure/interactive_guide.rst | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/galleries/users_explain/figure/interactive_guide.rst b/galleries/users_explain/figure/interactive_guide.rst index 21658bb5849b..41f54e4b20a7 100644 --- a/galleries/users_explain/figure/interactive_guide.rst +++ b/galleries/users_explain/figure/interactive_guide.rst @@ -405,17 +405,18 @@ The hook functions typically exhaust all pending events on the GUI event queue, run the main loop for a short fixed amount of time, or run the event loop until a key is pressed on stdin. -Matplotlib does not currently do any management of :c:data:`PyOS_InputHook` due -to the wide range of ways that Matplotlib is used. This management is left to -downstream libraries -- either user code or the shell. Interactive figures, -even with Matplotlib in "interactive mode", may not work in the vanilla python -repl if an appropriate :c:data:`PyOS_InputHook` is not registered. - -Input hooks, and helpers to install them, are usually included with -the python bindings for GUI toolkits and may be registered on import. +Interactive figures, even with Matplotlib in "interactive mode", may not work +in REPL if an appropriate :c:data:`PyOS_InputHook` is not registered. This +management is left to upstream libraries or downstream code -- either explicit +user code or shell initialization -- in all toolkits but native macOS. Input +hooks, and helpers to install them, are usually included with the Python +bindings for GUI toolkits and may be registered on import. For the macOS +native toolkit Matplotlib owns code that exposes the toolkit to Python and thus +we register :c:data:`PyOS_InputHook` on GUI application initialization. + IPython also ships input hook functions for all of the GUI frameworks -Matplotlib supports which can be installed via ``%matplotlib``. This -is the recommended method of integrating Matplotlib and a prompt. +Matplotlib supports which can be installed via ``%matplotlib``. This is the +recommended method of integrating Matplotlib and a prompt. IPython / prompt_toolkit