##// END OF EJS Templates
Convert "osx" gui framework to/from "macosx" in Matplotlib
Ian Thomas -
Show More
@@ -345,8 +345,10 b' def find_gui_and_backend(gui=None, gui_select=None):'
345 backend = matplotlib.rcParamsOrig["backend"]
345 backend = matplotlib.rcParamsOrig["backend"]
346 backend, gui = backend_registry.resolve_backend(backend)
346 backend, gui = backend_registry.resolve_backend(backend)
347 else:
347 else:
348 gui = _convert_gui_to_matplotlib(gui)
348 backend, gui = backend_registry.resolve_gui_or_backend(gui)
349 backend, gui = backend_registry.resolve_gui_or_backend(gui)
349
350
351 gui = _convert_gui_from_matplotlib(gui)
350 return gui, backend
352 return gui, backend
351
353
352 # Fallback to previous behaviour (Matplotlib < 3.9)
354 # Fallback to previous behaviour (Matplotlib < 3.9)
@@ -509,10 +511,28 b' def _list_matplotlib_backends_and_gui_loops() -> list[str]:'
509 if _matplotlib_manages_backends():
511 if _matplotlib_manages_backends():
510 from matplotlib.backends.registry import backend_registry
512 from matplotlib.backends.registry import backend_registry
511
513
512 ret = backend_registry.list_all() + backend_registry.list_gui_frameworks()
514 ret = backend_registry.list_all() + [
515 _convert_gui_from_matplotlib(gui)
516 for gui in backend_registry.list_gui_frameworks()
517 ]
513 else:
518 else:
514 from IPython.core import pylabtools
519 from IPython.core import pylabtools
515
520
516 ret = list(pylabtools.backends.keys())
521 ret = list(pylabtools.backends.keys())
517
522
518 return sorted(["auto"] + ret)
523 return sorted(["auto"] + ret)
524
525
526 # Matplotlib and IPython do not always use the same gui framework name.
527 # Always use the approprate one of these conversion functions when passing a
528 # gui framework name to/from Matplotlib.
529 def _convert_gui_to_matplotlib(gui: str | None) -> str | None:
530 if gui and gui.lower() == "osx":
531 return "macosx"
532 return gui
533
534
535 def _convert_gui_from_matplotlib(gui: str | None) -> str | None:
536 if gui and gui.lower() == "macosx":
537 return "osx"
538 return gui
General Comments 0
You need to be logged in to leave comments. Login now