@@ -39,6 +39,12 @@ isdisplayok() = displayable(MIME("image/png"))
39
39
# pygui(true/false). This is done by loading pyplot with a GUI backend
40
40
# if possible, then switching to a Julia-display backend (if available)
41
41
42
+ # like get(dict, key, default), but treats a value of "nothing" as a missing key
43
+ function getnone (dict, key, default)
44
+ ret = get (dict, key, default)
45
+ return ret === nothing ? default : ret
46
+ end
47
+
42
48
# return (backend,gui) tuple
43
49
function find_backend (matplotlib:: PyObject )
44
50
gui2matplotlib = Dict (:wx => " WXAgg" ,:gtk => " GTKAgg" ,:gtk3 => " GTK3Agg" ,
@@ -67,7 +73,7 @@ function find_backend(matplotlib::PyObject)
67
73
68
74
rcParams = PyDict (matplotlib[" rcParams" ])
69
75
default = lowercase (get (ENV , " MPLBACKEND" ,
70
- get (rcParams, " backend" , " none" )))
76
+ getnone (rcParams, " backend" , " none" )))
71
77
if haskey (matplotlib2gui,default)
72
78
defaultgui = matplotlib2gui[default]
73
79
@@ -77,7 +83,7 @@ function find_backend(matplotlib::PyObject)
77
83
if conda
78
84
if defaultgui == :qt || defaultgui == :qt4
79
85
# default to pyqt rather than pyside, as below:
80
- defaultgui = haskey ( rcParams," backend.qt4" ) ? qt2gui[ lowercase (rcParams[ " backend.qt4 " ])] : :qt_pyqt4
86
+ defaultgui = qt2gui[ lowercase ( getnone ( rcParams," backend.qt4" , " pyqt4 " ))]
81
87
if defaultgui == :qt_pyside
82
88
pyimport_conda (" PySide" , " pyside" )
83
89
else
0 commit comments