Hi everyone,
I am quite new to Pluto and I am a little stuck. Also I don’t know how to properly include Pluto code here, if this is possible, please tell me.
Core Problem:
As to my question: In principle I want to access the value of a Slider
in the same cell the Slider
is defined; let’s say as the maximum value of another Slider
. Ideally I want to do this inside a combine
environment. So my aim is something like this:
function test()
return combine() do Child
md"""
$(Child("First", @bind maxVal Slider(1:10, show_value=true, default=5)))
$(Child("Second", Slider(1:maxVal, show_value=true)))
"""
end
end
What happens now is that the second Slider
correctly starts with the range 1:5
but does not adjust it as I change the first Slider
.
I also tried to implement this in a simpler Version without combine
like this
md"""
$(@bind maxVal Slider(1:10, show_value=true, default=5))
$(Slider(1:maxVal, show_value=true))
"""
This does however behave in the same way. Weirdly enough I had a notebook where the latter still worked as intended but now I cannot replicate the behavior.
Is what I want to do possible in Pluto
? I would greatly appreciate any help.
I know that in this case it is easily fixed by just splitting to two cells. Therefore I included some further context to show why I am interested in this in the first place.
Motivation
I would like it in one cell for two reasons:
-
The actual code I have in mind is much more complicated and I would like to reuse
test()
in a number of places. So having it in one function is much more convenient. -
I actually want to have a variable controlling how often
test()
appears. So what I actually have in mind is
function multi_test(n)
return combine() do Child
inputs = [
md"""
Test $i : $(Child(test()))
"""
for i in 1:n
]
md"""
$inputs
"""
end
end
In this case all three ‘first’ Slider
s also behave the same due to the @bind
of maxVal
in test()
, which is an additional problem.
Thanks again for any help you can offer!