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

ipywidgets does not work in some situations #133

Open
MRYingLEE opened this issue Aug 6, 2024 · 3 comments
Open

ipywidgets does not work in some situations #133

MRYingLEE opened this issue Aug 6, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@MRYingLEE
Copy link

MRYingLEE commented Aug 6, 2024

For the following simple ipywidgets code:

%pip install ipywidgets
# Import IPython widgets for interactive input
from IPython.display import display
import ipywidgets as widgets

# Create a text box for user input
prompt_box = widgets.Textarea(
    value='Enter your prompt here...',
    placeholder='Type something...',
    description='Prompt:',
    disabled=False
)

# Create a button to generate text
button = widgets.Button(description="Generate Text")

# Function to handle button click
def on_button_click(b):
    prompt = prompt_box.value
    generated_text = "generate_text(prompt)"
    print("Prompt:", prompt)
    print("Generated Text:", generated_text)

# Attach the function to the button click event
button.on_click(on_button_click)

# Display the text box and button
display(prompt_box, button)

I works well in other Jupyter environment, such as Colab (https://colab.research.google.com/).
image

But the button clicking does not show anything in Jupyterlite, such as here (https://jupyterlite-pyodide-kernel.readthedocs.io/en/latest/_static/lab/index.html).

Please check.
Thanks,

@MRYingLEE MRYingLEE added the bug Something isn't working label Aug 6, 2024
@MRYingLEE
Copy link
Author

I used kernelspy(https://github.com/jupyterlab-contrib/jupyterlab-kernelspy) to check the messages after the button was clicked, and I saw:
image

So it seems the messaging system worked well but for some reason the messages were not processed well.

@MartinaMJ
Copy link

Hello. I have been facing this same problem. I noticed the kernel responds to the first few interactions but then stops responding. Did you find a solution or a possible cause?

@pierre-haessig
Copy link
Contributor

My jupyterlite deployment (e.g. https://pierre-haessig.github.io/pierre-notebooks/notebooks/?path=Frequency%20regulation%20nocode.ipynb) is also facing broken widget interaction, despite being up to date with jupyterlite-core==0.4.1 and jupyterlite-pyodide-kernel==0.4.2 just like the jupyterlite demo as per PR jupyterlite/demo#148

Also, the Lorenz attractor demo in jupyter.org's try-jupyter deployment is broken: https://jupyter.org/try-jupyter/lab/index.html?path=notebooks%2FLorenz.ipynb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants