fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.94k stars 285 forks source link

Feature request: multiple binds to the same variable #1097

Closed sefffal closed 3 years ago

sefffal commented 3 years ago

Hello and thank you all for the wonderful software that is Pluto notebooks! I have a feature request, that at first might sound odd, but bear with me.

It would be great if we could create multiple @bind calls that target the same variable, with the idea that if one is adjusted, all the others also adjust to reflect the same value.

One use case for this would be to have a slider for adjusting a variable, and also a text field for inputting an exact value. I often have a hard time choosing between a slider which is quick to adjust, and a text field where I can enter something exact.

A second use case, is when you a set of sliders and two or more ways of visualizing the results, e.g. two plots. It would be great if we could put a copy of the sliders above both plots and have them kept in sync.

Since I understand that the inputs are now synchronized across different browser sessions, perhaps this is not too intrusive of a change.

Also, in my mind, this doesn't break the reactive concept of Pluto. Unlike multiple variable declarations, this would be essentially just one declaration shown in multiple ways/locations.

Thanks for reading!

fonsp commented 3 years ago

Thanks for the tip! Can you try to rephrase your issue as a statement of a problem, rather than a direct feature request? Emphasize the problem you face, and make this the main subject of your message.

sefffal commented 3 years ago

Apologies, let me rephrase.

Inputs like sliders are great for quickly adjusting a bound variable to for example control a plot. E.g.: @bind a Slider(1:1000). However, it is often necessary to also switch to a precise value. I tried to create a second input @bind a NumberField(1:1000) to enter the variable, but this leads to an error that a is defined in multiple places.

So the problem is that we are currently able to interact with a notebook in exactly one way per variable.

My precise use case is this notebook I wrote that let's you visualize an orbit of a exoplanet by adjusting it's parameters: image The sliders work great for getting a feel, but it's not possible to also enter an exact value e.g. of a particular planet using a number field.