-
Notifications
You must be signed in to change notification settings - Fork 947
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
Make an Output model and view for the embedded widget manager #986
Comments
Issues shouldn't go on beta software, closing. |
@stsievert this feature requires the current state of master |
I am reopening this issue; I still can't embed widgets into a static HTML page (I am on beta6). My process for trying to embed widgets:
It's not clear from the documentation if I'm supposed to define my own HTML code for the widget. That's the reason the documentation goes into such detail on the JSON schema? |
Hi @stsievert Can you provide the generated html file? |
Here's a dropbox link: https://www.dropbox.com/s/b85fath9kiqxxv8/widget.html?dl=0 It implements the function above. |
You are missing the <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Your Title</title>
</head>
<body>
<!-- page content -->
</body>
</html> Maybe we should add a checkbox to wrap add the minimal html file content optionally. |
D'oh. I tried inserting the A checkbox would be a good idea. I expected standalone minimal widgets but it'd be a good idea to provide code to embed too. |
This is where it should be inserted. However, the dropbox link does not work anymore. |
Thanks. There is a legitimate issue here with the Output widget. |
To elaborate, it seems that the output widget model did not have state exposed (see below). However, even if it did have state, there would still likely be a problem since the output model and view is provided by the widget manager, and I'm not sure that the embedded widget manager has an output renderer.
|
I've updated the title to reflect what needs to be done. |
Now that we have the placeholder widget in case of missing model,, this will not crash pages with embedded widgets that include output widgets anymore. I removed the critical label. |
Pushing this forward to 6.1. |
Subscribing to this issue (sorry for the noise :-) |
I am anxious to know when it is resolved as well. On hold on a few projects unless this is resolved. |
Note to whoever does this: one way to do it without having to sync the output messages back to the kernel is to make a custom private field, say _output_messages, which is either null or the list of outputs. Generally, it will be null, but it has a custom serializer that puts in the output messages. Since we'll never save changes manually on this field, the output messages are never sent to the kernel. But saving the output widget state to the notebook will substitute in the output messages so they are persisted. On instantiation, the output widget will look at this field for an initial set of output messages, and then clear the field. |
You mean there is a temporary workaround? Can you please provide a tiny code example for us mere mortals who just want it to work? Really appreciate it! |
No, there isn't a temporary work around. That was just me jotting down a few notes about how it could be implemented for whoever volunteers to fix this issue. |
Note to self: I've been working on this, and maybe we shouldn't try to be so clever. It increases the sync bandwidth (quadratically, since each new message syncs everything), but makes the output widget much more understandable if the outputs are synced back to the server, and then we get saving and restoring for free. And if we do try to be clever, we should probably also strip the output messages to just the information needed to render them. For example, we don't need the username in the header, nor do we need the parent_header. It looks like we need just the message type and the content fields. |
This is fixed in #1294. |
Note to whoever develops this: with #1294, we have the output messages being stored. To do the rendering, I'd suggest writing an output widget very similar to the JupyterLab output widget (we'll have to create a default renderer, though). That will likely be much easier to package up than the classic notebook output area. In fact, we might be able to write a separate output widget package that can be used in both places, and just make an appropriate widget manager in each case (which would need context and rendermime attributes). |
Summary
Figure out how to save the state of the output widget (i.e., the output messages) and make an embedded widget manager output view.
Original issue
#16 is much appreciated! Thanks for this 👍
I have (tried) to embed a widget in a static webpage but haven't had any luck. I follow the documentation and select "Widgets > Embed widget" and copy that snippet into an HTML page. When I open that HTML page, I see a blank screen and can inspect to find a Javascript error:
This is with 1b9af7e and
python setup.py install
in a virtualenv. It's with a simple widget:The text was updated successfully, but these errors were encountered: