Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a flag which delays the init until IJulia cell #480

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,18 @@ end

# declare more globals created in __init__
const isjulia_display = Ref(true)
const delay_init_until_cell = Ref(false)
version = v"0.0.0"
backend = "Agg"
gui = :default

# initialization -- anything that depends on Python has to go here,
# so that it occurs at runtime (while the rest of PyPlot can be precompiled).
function __init__()
function init()
if !ispynull(plt)
return # we already initialized
end

isjulia_display[] = isdisplayok()
copy!(matplotlib, pyimport_conda("matplotlib", "matplotlib"))
mvers = matplotlib.__version__
Expand Down Expand Up @@ -222,6 +227,14 @@ function __init__()
init_colormaps()
end

function __init__()
if delay_init_until_cell[]
Main.IJulia.push_preexecute_hook(init) # delay init until cell execution if Jupyter
else
init()
end
end

function pygui(b::Bool)
if !b != isjulia_display[]
if backend != "Agg"
Expand Down