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

clear_output/display different behaviour Voila / Jupyter Lab vs Jupyter Notebook #3641

Open
DiegoF90 opened this issue Nov 28, 2022 · 1 comment

Comments

@DiegoF90
Copy link

DiegoF90 commented Nov 28, 2022

This issue is a duplicate of 1265 in Voila

Clearing or displaying an output widget seems to have a different behaviour on Voila / Jupyter Lab vs Jupyter Notebook.

I would expect the code below to show both "Text 1" and "Text 2" after every click on the checkbox. This is the behaviour seen in Jupyter Notebook but not using Voila nor Jupyter Lab.
In Voila/Jupyter Lab both "Text 1" and "Text 2" are shown on the first click, but only "Text 2" is shown on subsequent clicks.

import ipywidgets as widgets 

def build_o1():
    o1 = widgets.Output()
    t1 = widgets.Label(value="Text 1")
    with o1:
        display(t1)
        print("Text 2")
    return o1

o1 = build_o1()
o2 = widgets.Output()
c1 = widgets.Checkbox(description='Show/Hide')
display(c1)
display(o2)

def c1_event_handler(obj):
    if c1.value:
        with o2:
            display(o1)
    else:
        o2.clear_output()

c1.observe(c1_event_handler, names="value")
  • voila version 0.4.0
  • Operating System and version: Windows 10
  • Browser and version: Google Chrome [Version 107.0.5304.88 (Official Build) (64-bit)]
@vidartf
Copy link
Member

vidartf commented Nov 29, 2022

I did some basic level debugging: The issue can be narrowed further by observing that after o2.clear_output() is called, the "Text 2" output disappears from o1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants