First of all, I’m happy to say that the Interact package (now based on InteractBase) was updated to Julia 1.0 (thanks to the amazing help of many people, esp. the heroic JuliaRobotics developers who fixed a large number of relevant packages).
After a lengthy design discussion with
@shashi at JuliaCon, we have finalized the recipe framework (a way for the user to define their own recipes), with a focus on simplicity and composability.
In short it works as follows: a
Widget is basically a
mutable struct with some components, an output and a layout. The
Interact.@map macro allows to use
Widgets like normal values (for example, a slider will be replaced by the numerical value it represents) and the result will be updated when it changes. Here for example we can create a widget with 3 components (
color1, color2, legendpos) and a plot as output. The layout will be the default (components and then the output are disposed vertically one after another).
using Interact using Interact: @map using Colors, Plots function myplot(color1, color2, legendpos) output = Interact.@map plot([sin, cos], color = [&color1 &color2], legend = &legendpos, label = ["sin" "cos"]) Widget([:color1 => color1, :color2 => color2, :legendpos => legendpos], output = output) end ui = myplot(colorpicker(), colorpicker(), togglebuttons([:topleft, :topright, :bottomleft, :bottomright]));
However this design is very flexible, we can create our own
colorpicker and use it instead:
function mycolorpicker() r = slider(0:255, label = "red") g = slider(0:255, label = "green") b = slider(0:255, label = "blue") output = @map Colors.RGB(&r/255, &g/255, &b/255) wdg = Widget(["r" => r, "g" => g, "b" => b], output = output) # it outputs a color, so it can be used as colorpicker @layout! wdg vbox(:r, :g, :b) # custom layout: only display the three sliders aligned vertically but don't display the output color ui = myplot(mycolorpicker(), mycolorpicker(), togglebuttons([:topleft, :topright, :bottomleft, :bottomright]));
For more details be sure to checkout the Interact docs (esp. the Custom widgets section and the tutorial).
Interact apps are reasonably easy to deploy: see here for details. As an example, you can check out the GitHub repository a pure Julia website of Interact demos here. The site is not yet up online but you can easily set it up on your machine (or on your server) following the instructions on the README, then check it out at