-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Select return arbitrary values instead of strings #3
Comments
Unfortunately not :( but I agree that this would be very useful! The I have some ideas that would solve that issue, the main one being the possibility of giving a preprocessor function to I am not yet sure how to expose this API. Options are:
As you probably found yourself, the workaround is to create two cells: @bind M_name Select(["M1" => "Diagonal Matrix", "M2" => "Symmetric Matrix"]) M = Dict("M1" => M1, "M2" => M2)[M_name] |
Also, do you think that the |
I'm not very familiar with how Observables work and how exactly every variable (cell) in Pluto is an observable but shouldn't it be possible to have some observable that listens to the current string "returned" by select and which then itself changes its value according to a map from the string to an actual other observable. So something along the lines of
|
In response to the first sentence: Pluto doesn't use variables as the unit of reactivity, but cells - your variables are not observables in the traditional sense. For example, in these two cells: for i in 1:4
global a = i
end dosomething(a) the function This problem cannot be solved by adding a new macro to your notebook, or to this package 😢. I could explain this in more detail if you like, but the gist is: Setting a |
Ok. That clarifies it a bit! Thank you. Regarding your other question: maybe some description in the example notebook or the documentation of Slider together with the two-cell-pattern-solution would be good. |
(note to self) One option is to check for a two-argument overload for Base.get(x::MyType) = # intial value
Base.get(x::MyType, val) = # value returned to julia as function of val this function is used as the preprocessor, with the JS-returned object as second argument. EDIT: we changed |
I would like to use the
Select
element to select different matrices with different names in the select combobox. I want the name to be displayed in the combobox and the matrix bound to the variable I@bind
theSelect
to. SoThis currently does not work since
Select
binds the keys (which currently have to be strings) of the passed dict to the variable and displays the values.Can we just change
Select
to support arbitrary keys instead just Strings?The text was updated successfully, but these errors were encountered: