question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interactivity with / without ThebeLab

See original GitHub issue

Hi !

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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
akhmerovcommented, Sep 18, 2019

No problem at all.

  1. 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.

  2. Indeed holoviews and adaptive use static widgets to enable rich UI.

0reactions
jbwestoncommented, Oct 23, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Thebe — Thebe documentation
Thebe turns your static HTML pages into interactive ones, powered by a kernel. ... thebe has been added as an alias for thebelab...
Read more >
how to go interactive using local server ? · Issue #175
On one side the doc shows how to go interactive via Thebelab / binder On another side Thebelab doc has an example showing...
Read more >
Launch buttons for interactivity — Data Science Study
To make your content interactive without requiring readers to leave the current page, you can use a project called Thebe. This provides you...
Read more >
elixir - How might we use ThebeLab to execute a code cell ...
I'm trying to embed code cells from a jupyter notebook running an ielixir kernel by using Thebe Lab so that I can create...
Read more >
Launch into interactive computing interfaces
This lets readers quickly interact with your content in a traditional coding interface. They do so by clicking a Launch Button that takes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found