JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
299 stars 54 forks source link

@bind macro should bind a variable to a slider instead of its value #299

Closed scls19fr closed 4 months ago

scls19fr commented 4 months ago

Hello,

I'm working both with Marimo and Pluto.jl and found a notable difference with how UI works.

With Marimo you can do thinks like

f1 = mo.ui.slider(start=100_000, step=100, stop=10_000_000, value=500_000)
V1 = mo.ui.slider(start=0, step=0.1, stop=1, value=1.0)

f2 = mo.ui.slider(start=20, step=1, stop=20_000, value=10_000)
V2 = mo.ui.slider(start=0, step=0.1, stop=1, value=0.5)

and have a cell with Markdown like (in an other cell)

mo.md(f"""# Modulation d'amplitude AM

## Porteuse

### Fréquence
f1 = {f1.value} Hz

{f1}

### Amplitude
V1 = {V1.value} V

{V1}

## Signal modulant
### Fréquence
f2 = {f2.value} Hz

{f2}

### Amplitude
V2 = {V2.value} V

{V2}
""")

But with Pluto @bind macro bind a slider to its value not to the slider itself (I'm not english native speaker so please excuse if that's not clear)

This kind of mechanism is really interesting as you can define in an hidden cell all you UI objects and use them in a Markdown cell.

What is your opinion about that?

Kind regards

fonsp commented 4 months ago

In Pluto you can do this too!

slider = @bind x Slider(1:10)
md"""
Here is the slider again: $slider
"""
scls19fr commented 4 months ago

Thanks @fonsp maybe it could be worth mentioning that in doc https://featured.plutojl.org/basic/plutoui.jl