Interactivity with / without ThebeLab
See original GitHub issueHi !
I’m trying to add some interactivity to a page using .. jupyter-execute::
, but unfortunately my approach is not working and I am not grasping the key issues involved. I provide a simple example that runs perfectly in Jupyter Lab, with an IntSlider input whose ‘value’ gets squared and displayed as a Label’s ‘value’. Everything happens in the callback registered using the .observe
handler:
import ipywidgets as widgets
val = 2
inp = widgets.IntSlider(value = val, min = 1, max = 10,
description = 'x', readout = False)
out = widgets.Label(r'\({0}^2 = {1}\)'.format(val,val*val))
def handle_inp_change(value):
out.value = r'\({0}^2 = {1}\)'.format(value.new,value.new*value.new)
inp.observe(handle_inp_change,'value')
display(widgets.HBox([inp,out]))
So this works fine both in a Jupyter Lab cell, and within my sphinx-rendered page when I activate ThebeLab and run the cell using the ‘run’ button (the code is properly formatted in markdown for ..jupyter-execute::
). But … if I only load the page in the browser without activation of ThebeLab, it occurs that while the slider responds to mouse actions, nothing happens within the Label. If I’m understanding correctly, ..jupyter-execute::
creates a cell with nbconvert and runs it “somewhere”, isn’t it ?
Sorry for the lengthy description, but I am sure that this problem is a good instance of many other possible designs that need to be interactive. I’ll be glad to explain again or provide more info, and certainly will be more than happy to read your feedback.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
No problem at all.
The machinery for running thebelab is based on limited resources kindly provided by binder. One can in principle request a binder every time the user starts a new browsing session, but that would be rather resource-inefficient. I see that jupyter-book uses
nbinteract
, which also goes via binder though, and they should be equally aware about the resource usage. So this would indeed be possible, although I have mixed feelings about it.Indeed holoviews and adaptive use static widgets to enable rich UI.
@oscarys it seems like your question was answered so I’m going to close this issue.
If I have misunderstood feel free to re-open.