I did this once in order to get convinced that writing such GUIs was indeed possible. This was my first and only time using Blink and Interact, and I did not really use this UI for anything useful. But here is the code in case it would be helpful for you to get started with this framework:
using Interact
using Blink
using CSSUtil
using WebIO
# Not sure how to display plain text messages without defining such custom widgets...
htmldiv(name, observable) = Widget{name}(OrderedDict(),
output=map(val->dom"div"(string(val)), observable))
htmlspan(name, observable) = Widget{name}(OrderedDict(),
output=map(val->dom"span"(string(val)), observable))
# Two parameters, linked to slider widgets
x = slider(1:10, label = "x", value = 1)
y = slider(1:10, label = "y", value = 1)
# A third parameter, computed by combination of the other two
param = Observable(0)
function update_xy(_=nothing)
param[] = x[] + y[]
end
on(update_xy, x)
on(update_xy, y)
update_xy() # First manual update to display a consistent state on UI startup
# A widget allowing to choose a file path
f = filepicker(label="Choose a file..."; multiple=false, accept="*")
# A button to run the computation
b = button("Go")
# A message displayed at the bottom
message = Observable("")
# This condition will be used to notify the main task when the computation is done
done = Condition()
# Mock-up computation happening on button click
on(b) do _
for i in 5:-1:1
message[] = string("Performing long computation involving parameter $(param[]) ",
"and file $(f[]): $i")
sleep(1)
end
message[] = "Computation complete!"
# Notify the main task
notify(done)
end
# Create the window and layout the widgets in it
w = Window()
ui = pad(1em,
vbox(pad(1em,
vbox(x, y,
hbox(node(:span, "param : x + y = "), htmlspan(:param, param)))),
pad(1em, f),
pad(1em, b),
pad(1em, htmldiv(:message, message))))
body!(w, ui)
# Wait until the computation is finished
wait(done)
sleep(1)
Screenshot:
At the time when I made this experiment, I tested this on Linux and generated a system image for it. AFAIR I did not have any problem with PackageCompiler. I’m not sure whether I actually tested this on Windows.
Again, this might very well be un-idiomatic, and I’ll probably not be able to answer any follow-up question you might have. But hopefully someone more knowledgeable will chime in and we’ll both learn something!