Skip to content

Cannot render ipywidgiets parts in .ipynb documents #260

Description

@tsingfei

My requirement is to support interactive widgets in the rendering of the document, so that readers can understand the program in a more user-friendly way. But I find that it seems that mkdocs-jupyter does not support rendering ipywidgets widgets.

My .ipynb file is like:

import asyncio
import ipywidgets as widgets

from IPython.display import display

terminal_input = widgets.HBox([
    widgets.Label("Input your next command:"),
    (command_input := widgets.Text(placeholder="Type command...")),
    (command_button := widgets.Button(description="Submit"))
])

terminal_output = widgets.Textarea(
    value='',
    layout=widgets.Layout(
        border='1px solid #888',
        color="#eee",
        width="100%",
        style={'textarea': {'background-color': '#2c3e50', 'color': '#ecf0f1'}},
    )
)

async def on_button_click(b):
    command_str = command_input.value.strip()
    command_input.value = ''
    terminal_output.value += f"> {command_str}\n"
    command_input.focus()

# command_button.on_click(lambda b: asyncio.create_task(on_button_click(b)))

display(
    widgets.VBox([
        terminal_input,
        terminal_output,
    ])
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions