Skip to content

Commit e1c6111

Browse files
committed
launch single electron window from make
1 parent da1b893 commit e1c6111

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

NetworkDynamicsInspector/ext/ElectronExt.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ function NDI.get_electron_window()
5454
# check window size
5555
if NDI.CURRENT_DISPLAY[] isa NDI.ElectronDisp
5656
x, y = NDI.CURRENT_DISPLAY[].resolution
57-
run(NDI.get_electron_app(),
58-
"BrowserWindow.fromId($(window.id)).setSize($x, $y)")
57+
try
58+
run(NDI.get_electron_app(),
59+
"BrowserWindow.fromId($(window.id)).setSize($x, $y)")
60+
catch e
61+
@warn "Could not resize window: $e"
62+
end
5963
end
6064

6165
return window

NetworkDynamicsInspector/src/serving.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ function save_electron_screenshot(path=joinpath(@__DIR__, "screenshot.png"))
145145
});
146146
"""
147147
wait_for()
148+
sleep(1) # make sure that axis updates and so on
148149
d = run(get_electron_app(), js)
149150
nothing
150151
end

docs/make.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
using Documenter
44
using NetworkDynamics
55
using NetworkDynamicsInspector
6+
using NetworkDynamicsInspector: NetworkDynamicsInspector as NDI
67
using SciMLBase
78
using Literate
89
using ModelingToolkit
910
using DocumenterInterLinks
11+
using Electron
12+
13+
14+
@info "Create global electron window"
15+
NDI.CURRENT_DISPLAY[] = ElectronDisp(resolution=(1200,1020)) # hide
16+
NDI.get_electron_window()
1017

1118
links = InterLinks(
1219
"DiffEq" => "https://docs.sciml.ai/DiffEqDocs/stable/",
@@ -85,6 +92,9 @@ else # local build
8592
makedocs(; kwargs_warnonly...)
8693
end
8794

95+
@info "Close global electron window"
96+
NDI.close_display()
97+
8898

8999
# warnonly options
90100
# :autodocs_block

docs/src/inspector.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# NetworkDynamicsInspector
1+
# Interactive Solution Inspection
2+
3+
Interactive solution inspection tool based on [WGLMakie](https://makie.org/website/) and [Bonito](https://github.com/SimonDanisch/Bonito.jl) are provided through the helper package `NetworkDynamicsInspector`.
4+
25

36
```@example ndi
47
using NetworkDynamics
@@ -56,13 +59,12 @@ function get_sol(;limit=1.0)
5659
end
5760
5861
sol = get_sol()
59-
60-
61-
62-
NDI.CURRENT_DISPLAY[] = ElectronDisp(resolution=(1000,1000)) # hide
63-
@info "open gui"
64-
inspect(sol)
65-
NDI.save_electron_screenshot("screenshot.png")
66-
NDI.close_display()
62+
inspect(sol; restart=false, reset=true)
63+
NDI.wait_for()
64+
define_timeseries!([
65+
(; selcomp=[EIndex(i) for i in 1:7], states=[:P])
66+
])
67+
NDI.save_electron_screenshot("screenshot.png") #hide #md
68+
nothing #hide #md
6769
```
68-
![screenshot](screenshot.png)
70+
![screenshot](../screenshot.png)

0 commit comments

Comments
 (0)