You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to detect which frontends are connected #11920
It is impossible to tell by design. It is possible for more than one front end to connect which makes any automatic configuration based on that problematic.
I think the protocol is carefully designed to make sure you can not tell. I have gone down this road with Matplotlib and concluded it was not possible (and mostly agree with the design).
So how does matplotlib detect which backwnd to use?
I think it doesn't. It's up to the frontend to try to use the Matplotlib backend set by the user.
For example, if you set %matplotlib notebook then interactive plots will be rendered as expected inside the notebook, but nothing will be shown in Spyder (and no error will be generated) because qtconsole can't handle Javascript content.
This limitation will be overcome in our side once we add a new pane in Spyder capable of rendering any web content that comes from the kernel. This is our top priority for Spyder 5, to be released next year.
Activity
tacaswell commentedon Oct 20, 2019
It is impossible to tell by design. It is possible for more than one front end to connect which makes any automatic configuration based on that problematic.
hmaarrfk commentedon Oct 20, 2019
Hmmm. Is it possible to tell which frontend is running the current lines of code?
tacaswell commentedon Oct 23, 2019
I think the protocol is carefully designed to make sure you can not tell. I have gone down this road with Matplotlib and concluded it was not possible (and mostly agree with the design).
hmaarrfk commentedon Oct 23, 2019
So how does matplotlib detect which backwnd to use? Could other libraries use the same detection mechanism? Qt vs Web vs tk???
ccordoba12 commentedon Oct 23, 2019
I think it doesn't. It's up to the frontend to try to use the Matplotlib backend set by the user.
For example, if you set
%matplotlib notebookthen interactive plots will be rendered as expected inside the notebook, but nothing will be shown in Spyder (and no error will be generated) because qtconsole can't handle Javascript content.This limitation will be overcome in our side once we add a new pane in Spyder capable of rendering any web content that comes from the kernel. This is our top priority for Spyder 5, to be released next year.
tacaswell commentedon Oct 24, 2019
The only 'auto' thing we do is try to detect if there is a running GUI event loop and we use that one (which is something that is fully on the kernel side of things, see https://github.com/matplotlib/matplotlib/blob/349e2e9e8a33c5a45d2935aae86561bdea10e55b/lib/matplotlib/cbook/__init__.py#L39-L76 ).