Skip to content

Commit

Permalink
ENH: add function to close plot window.
Browse files Browse the repository at this point in the history
Closes #220
  • Loading branch information
sglyon committed Sep 6, 2018
1 parent c343c50 commit 2650ab4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ mutable struct SyncPlot
plot::PlotlyBase.Plot
scope::Scope
options::Dict
window::Union{Nothing,Blink.Window}
end

Base.getindex(p::SyncPlot, key) = p.scope[key] # look up Observables
Expand Down Expand Up @@ -191,7 +192,7 @@ function SyncPlot(
# to us
on(scope["image"]) do x end

SyncPlot(p, scope, options)
SyncPlot(p, scope, options, nothing)
end

function plot(args...; options=Dict(), kwargs...)
Expand All @@ -205,8 +206,14 @@ function Base.copy(sp::SyncPlot)
end

function Base.display(::REPL.REPLDisplay, p::SyncPlot)
w = Blink.Window()
Blink.body!(w, p.scope)
p.window = Blink.Window()
Blink.body!(p.window, p.scope)
end

function Base.close(p::SyncPlot)
if p.window !== nothing && Blink.active(p.window)
close(p.window)
end
end

function send_command(scope, cmd, args...)
Expand Down

0 comments on commit 2650ab4

Please sign in to comment.