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

[WIP] Export output widget in embed bundle #1380

Closed
wants to merge 3 commits into from

Conversation

pbugnion
Copy link
Member

Prior to this PR, the output widget could not be embedded. Addresses issue #986 .

@pbugnion
Copy link
Member Author

My initial approach for this is to start developing this is as an independent widget inspired by the jupyterlab output widget, then see how much code can be factored out (and how).

@jasongrout
Copy link
Member

As a second phase to this, I was imagining that the embedded widget manager could expose an API for adding more rendermime renderers to the jlab output widget as well.

@jasongrout
Copy link
Member

For the initial approach, I would start by importing the jupyterlab output and rendermime packages and using the jlab output widget directly. It was designed to be usable outside of jlab.

@jasongrout
Copy link
Member

Thanks so much for taking this on! It's one of the biggest blockers we have for releasing 7.0.

@pbugnion
Copy link
Member Author

For the initial approach, I would start by importing the jupyterlab output and rendermime packages and using the jlab output widget directly. It was designed to be usable outside of jlab.

Thanks -- that answers one of my questions.

Thanks so much for taking this on! It's one of the biggest blockers we have for releasing 7.0.

Thanks! I expect I'll have several questions along the way.

@pbugnion
Copy link
Member Author

As a second phase to this, I was imagining that the embedded widget manager could expose an API for adding more rendermime renderers to the jlab output widget as well.

Is the intention here to allow users to write custom renderers in the HTML documents in which the widgets are embedded?

The output widget now displays the content of the model state (at least for very
simple states like streams).
@pbugnion
Copy link
Member Author

pbugnion commented May 24, 2017

For reference, I'm currently using this test rig (I'll add more complex outputs when I have basic ones working):

<html>
    <head>
        <!-- <script src="https://unpkg.com/jupyter-js-widgets@~3.0.0-alpha.6/dist/embed.js"></script> -->
        <script src="./embed.js"></script>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

        <script type="application/vnd.jupyter.widget-state+json">
         {
             "version_major": 2,
             "version_minor": 0,
             "state": {
                 "799936c00fbc4187a4560a5e7a6ed5f4": {
                     "model_name": "LayoutModel",
                     "model_module": "jupyter-js-widgets",
                     "model_module_version": "3.0.0",
                     "state": {}
                 },
                 "1ad16665c76a44908e4c269821dcedbd": {
                     "model_name": "OutputModel",
                     "model_module": "jupyter-js-widgets",
                     "model_module_version": "3.0.0",
                     "state": {
                         "_view_module": "jupyter-js-widgets",
                         "_dom_classes": [],
                         "msg_throttle": 1,
                         "outputs": [
                             {
                                 "output_type": "stream",
                                 "name": "stdout",
                                 "text": "hi\n"
                             }
                         ],
                         "_model_module_version": "3.0.0",
                         "_view_count": null,
                         "_view_module_version": "3.0.0",
                         "layout": "IPY_MODEL_799936c00fbc4187a4560a5e7a6ed5f4",
                         "_model_module": "jupyter-js-widgets"
                     }
                 }
             }
         }
        </script>

    </head>

    <body>
        <h1>Output embedding example</h1>
        <div id="widget-embedded-here">
            <script type="application/vnd.jupyter.widget-view+json">
             {
                 "model_id": "1ad16665c76a44908e4c269821dcedbd",
                 "version_minor": "0",
                 "version_major": "2"
             }
            </script>
        </div>
    </body>
</html>

This allows outputs with rich displays (like dataframes) to be displayed
correctly.

Having to amend the main widgets stylesheet to provide something that is
normally provided by the notebook or JupyterLab seems inelegant. It may be worth
splitting out the embed stylesheet.
Copy link
Member

@jasongrout jasongrout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saw your note on the stylesheet. We should really (eventually) split out the entire embed manager into a separate npm package. Perhaps now is a good time to do so?

@pbugnion
Copy link
Member Author

That makes sense. I'll put in a (separate) tentative PR for splitting out the embed manager into a separate module.

@pbugnion pbugnion mentioned this pull request May 29, 2017
5 tasks
@jasongrout jasongrout added this to the 7.0 milestone May 30, 2017
@pbugnion
Copy link
Member Author

pbugnion commented Jun 5, 2017

I'm closing this in favour of #1410 . This has diverged from master sufficiently that it would be harder to merge than to just start again.

@pbugnion pbugnion closed this Jun 5, 2017
@jasongrout
Copy link
Member

Thanks @pbugnion - we're moving pretty fast in master.

@pbugnion pbugnion deleted the embed-output-widget branch June 5, 2017 14:17
@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 13, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants