Closed TheCedarPrince closed 3 years ago
If you don't get an answer here, consider using https://docs.julialang.org/en/v1.7-dev/stdlib/REPL/#MultiSelectMenu and https://github.com/JuliaLang/julia/blob/b0fc9bacb9244959a7c1bd34aa0897828602d220/stdlib/REPL/src/TerminalMenus/MultiSelectMenu.jl#L39-L55
I would love to use something like that, but I am trying to create an interface in a Jupyter notebook environment. So, sadly, that wouldn't work for my particular use case as there aren't supported in Jupyter NBs at the moment. Thanks though @timholy !
You can use the keyword value
to set the value:
options = ["a", "b", "c"]
value = ["a", "c"]
checkboxes(options, value = value)
(both options and value can be Observable
s).
It is documented here, but it looks like the default value is wrong, I think it initializes with value = []
.
That did it! Thanks @piever!
Where is the error? I can make a quick docs PR to fix it.
Also, could I add this as an example for pre-checking checkboxes as you showed here? That wasn't apparent - at least to me - from the docs.
Where is the error? I can make a quick docs PR to fix it.
In the docs, it says that if you don't pass a value
explicitly, it defaults to first(values(options))
, but actually the default is valtype(options)[]
. Docs PR with this fix and a "pre-checked" example would be great!
Sweet! @piever - could I ping you when the PR is ready? Thanks!
Sure! I'll be notified either way as I'm watching the repo.
PR opened here: piever/InteractBase.jl#159 @piever - thanks for the help! :smile:
Hey there, I tried asking for help on the Julia Slack, Zulip, and Discourse, but no luck anywhere. Here is the question I had:
How do I use Interact.jl to present a list of checkboxes with some of the boxes already checked off? Tried following the documentation and couldn’t figure out how to set specific checkboxes to true (i.e. checked off).
What I have currently, is this:
The boxes are empty by default. What I would like to have happen is for a few boxes to already be checked off when they are first shown like this:
The code I have been using is:
What I don't understand is why the checkbox for "a" and "c" is not already showing up checked off. Any thoughts?
Thanks!