outputs icon indicating copy to clipboard operation
outputs copied to clipboard

interact-based widgets do not render

Open captainsafia opened this issue 6 years ago • 8 comments

In the Using Interact example notebook, the horizontal slider does not render when the interact code is executed.

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
def f(x):
    return x
interact(f, x=10);

captainsafia avatar Oct 28 '19 17:10 captainsafia

I did some investigating on this, and it is caused by the model being different than the other models we deal with. Instead of having the information we normally expect, it has a list of child models. I'll try to get a fix for this tomorrow.

miduncan avatar Nov 05 '19 02:11 miduncan

If that’s the case, then it is probably also related to the issue around Boxes and Accordions not rendered correctly because they are child_views.

Let us know what you find out.

captainsafia avatar Nov 05 '19 17:11 captainsafia

nteract/nteract#4640 for sake of tracking. I'll investigate both

miduncan avatar Nov 05 '19 19:11 miduncan

I was able to dig deeper into this, and it may be a tricky one to fix. It basically follows these steps:

  1. Kernel sends a message for a new model, "model_1", with a state like this (notice the empty children):
state: {
  box_style: ""
  children: []
  layout: "IPY_MODEL_38e17f2743414a148d7ea0856a910eec"
  _dom_classes: ["widget-interact"]
  _model_module: "@jupyter-widgets/controls"
  _model_module_version: "1.5.0"
  _model_name: "VBoxModel"
  _view_count: null
  _view_module: "@jupyter-widgets/controls"
  _view_module_version: "1.5.0"
  _view_name: "VBoxView"
}
  1. After some time, kernel sends an "update" message to "model_1"
data: {
  buffer_paths: []
  method: "update"
  state: {
    children: ["IPY_MODEL_model_2",  IPY_MODEL_model_3"]
  }
}
  1. Kernel sends the "application/vnd.jupyter.widget-view+json" message we direct to WidgetDisplay
application/vnd.jupyter.widget-view+json: {
  model_id: "model_1"
  version_major: 2
  version_minor: 0
}
  1. When widget looks up the "model_1", it gets the data from step 2. The information in step 1 is lost
  2. Error is thrown because no view information is provided to create_widget

miduncan avatar Nov 06 '19 02:11 miduncan

I'm guessing this is the same issue with Accordion and Tabs, as the model state given to them also only has children. No view information.

miduncan avatar Nov 06 '19 02:11 miduncan

Rendering issues cause by nteract/outputs#3

miduncan avatar Nov 08 '19 01:11 miduncan

@captainsafia , we are also running into issues with nteract and interact ipywidgets in our most recent project. Are there any plans to support this in near future?

xinyi-joffre avatar Aug 10 '22 20:08 xinyi-joffre

Same issue with an asynchronous slider response, is there a list of widgets that can be used with an asynchronous response?

vveralag avatar Aug 01 '23 20:08 vveralag