Skip to content
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

Allow nested manipulates #164

Closed
djsegal opened this issue May 7, 2017 · 12 comments
Closed

Allow nested manipulates #164

djsegal opened this issue May 7, 2017 · 12 comments

Comments

@djsegal
Copy link

djsegal commented May 7, 2017

I want to be able to nest manipulates where inner ones are affected by outer ones.

This currently causes the jupyter notebook to stall out


Simple example:

some_dict = Dict(
  "arc" => 3.3, 
  "act1" => 6.8, 
  "act2" => 9.6
)

@manipulate for design=["arc", "act1", "act2"]
    @manipulate for r=linspace(0, some_dict[design], 25)
         cur_design = load_design(design)
         foo(cur_design, r)
    end
end;
@JobJob
Copy link
Member

JobJob commented May 8, 2017

Yep, @manipulate has limitations. If you want to build more complicated UIs you're better off handling the widgets and signals manually. E.g. for the above:

some_dict = Dict(
  "arc" => 3.3, 
  "act1" => 6.8, 
  "act2" => 9.6
)

design_chooser = togglebuttons(["arc", "act1", "act2"]; label="design")
range_sig = map(design_val->linspace(0, some_dict[design_val], 25), signal(design_chooser))
r_slider = slider(value(range_sig); label="r")
set!(r_slider, :range, range_sig) # update the slider's range when the range_sig updates
design_updater = map(signal(design_chooser), signal(r_slider)) do design, r
    cur_design = load_design(design)
    foo(cur_design, r)
end
display.([design_chooser, r_slider, design_updater]);

@JobJob
Copy link
Member

JobJob commented May 15, 2017

The stalling was caused by a couple of bugs arising from recent changes in Reactive to get it work on 0.6. The PRs to fix those, and another issue your code brought up for me, (JuliaGizmos/Reactive.jl#138 and JuliaGizmos/Reactive.jl#139) should be merged soon. In the meantime I'd recommend trying Pkg.checkout("Reactive", "job/flatten-bind-fix") it should be much more reliable. Unfortunately it won't fix the OP, but you'll see that it almost works, just a new slider for r gets created every time you choose a new design.

This is strongly related to #12 and it would be nice to fix this. I'm hopeful I'll get a chance to as part of my GSoC work on Interact

Anyway, thanks for the report, it helped me track down a couple of subtle bugs in Reactive.

@JobJob
Copy link
Member

JobJob commented May 16, 2017

Those PRs are merged. Party time all round 🎉

@djsegal
Copy link
Author

djsegal commented Jun 12, 2017

@JobJob just confirming this is ok to close?

@djsegal djsegal closed this as completed Jun 12, 2017
@djsegal djsegal reopened this Aug 8, 2017
@djsegal
Copy link
Author

djsegal commented Aug 8, 2017

If you click an outer scope option, the inner scope options get re-appended

i.e.

screen shot 2017-08-08 at 1 04 45 pm

@djsegal
Copy link
Author

djsegal commented Aug 12, 2017

@JobJob, are you able to reproduce this?

@JobJob
Copy link
Member

JobJob commented Aug 13, 2017

Yep. Leave this issue open so it stays on the radar

@djsegal
Copy link
Author

djsegal commented Aug 25, 2017

I'm interested in helping fix this issue. Do you know where abouts to look?


edit:

the simplest way would probably be to:

  • add html ids to the jupyter-widgets divs
  • use javascript to enforce unique ids within a cell

i.e. a toggle over "temperature" would have the id #jupyter-toggle-temperature or something

@JobJob
Copy link
Member

JobJob commented Aug 25, 2017

Yeah, it's gonna be pretty fiddly, and IJulia specific. Probably better to try implement it in InteractNext once it's released, which should be next week, though expect it to be a bit brittle at first.

A basic approach that might work is to get the widgets to become Signal{Widget}s, and then Interact can handle them updating.

As I wrote above, if you want to build more complicated UIs, you're probably better off handling the widgets and signals manually for now, rather than using manipulate.

@jasongrout
Copy link

FYI, supporting interacts inside interacts works well (at least in python) in ipywidgets 7.

@piever
Copy link
Collaborator

piever commented Jul 11, 2018

I just tried:

using InteractBulma
some_dict = Dict(
  "arc" => 3.3, 
  "act1" => 6.8, 
  "act2" => 9.6
)

@manipulate for design=["arc", "act1", "act2"]
    @manipulate for r=linspace(0, some_dict[design], 25)
         r
    end
end

and it seems to just work. Let me know if there are more things to be done on this front or whether the issue can simply be closed.

@djsegal
Copy link
Author

djsegal commented Jul 11, 2018 via email

@piever piever closed this as completed Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants