##// END OF EJS Templates
Convert "osx" gui framework to/from "macosx" in Matplotlib (#14420)...
M Bussonnier -
r28753:85bb5302 merge
parent child Browse files
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
@@ -276,11 +276,11 b' def test_figure_no_canvas():'
276 # name is gui
276 # name is gui
277 ("gtk3", "gtk3", "gtk3agg"),
277 ("gtk3", "gtk3", "gtk3agg"),
278 ("gtk4", "gtk4", "gtk4agg"),
278 ("gtk4", "gtk4", "gtk4agg"),
279 ("headless", "headless", "agg"),
279 ("headless", None, "agg"),
280 ("osx", "osx", "macosx"),
280 ("osx", "osx", "macosx"),
281 ("qt", "qt", "qtagg"),
281 ("qt", "qt", "qtagg"),
282 ("qt5", "qt5", "qt5agg"),
282 ("qt5", "qt5", "qt5agg"),
283 ("qt6", "qt6", "qt6agg"),
283 ("qt6", "qt6", "qtagg"),
284 ("tk", "tk", "tkagg"),
284 ("tk", "tk", "tkagg"),
285 ("wx", "wx", "wxagg"),
285 ("wx", "wx", "wxagg"),
286 # name is backend
286 # name is backend
@@ -301,8 +301,6 b' def test_figure_no_canvas():'
301 ("qtcairo", "qt", "qtcairo"),
301 ("qtcairo", "qt", "qtcairo"),
302 ("qt5agg", "qt5", "qt5agg"),
302 ("qt5agg", "qt5", "qt5agg"),
303 ("qt5cairo", "qt5", "qt5cairo"),
303 ("qt5cairo", "qt5", "qt5cairo"),
304 ("qt6agg", "qt", "qt6agg"),
305 ("qt6cairo", "qt", "qt6cairo"),
306 ("tkagg", "tk", "tkagg"),
304 ("tkagg", "tk", "tkagg"),
307 ("tkcairo", "tk", "tkcairo"),
305 ("tkcairo", "tk", "tkcairo"),
308 ("webagg", "webagg", "webagg"),
306 ("webagg", "webagg", "webagg"),
General Comments 0
You need to be logged in to leave comments. Login now