Widgets Disappear after 1 or 2 seconds

I am trying to create an extension for jupyter notebook but the extension does not seem to work as expected .
The extension basically loads the widgets on startup of each new notebook .
The issue is the widgets load for a brief second and then disappear .
when i run the cell again the widgets work as expected.

Any suggestions?

We’ll need more information to give you pointers on what you could investigate, such as the version of JLab, is this ipywidgets that you are talking about (if so, what version), and a simple reproducible example would be great.

I had the same issue. I created a widget that chooses some parameter and generates plotly chart after each change. Entire chart with widget kept disappearing. I don’t fully understand the solution that helped me, but it is a creating a fast artificial plot on the very beginning of the app. For me this was:

from plotly.subplots import make_subplots
import plotly.graph_objects as go
import time
from IPython.display import clear_output

def test_plotly():
    fig = make_subplots(rows=1, cols=1)
    fig.add_trace(
        go.Scatter(x=[],y=[]), 
        row=1, col=1
            )
    fig.update_layout(height=10, width=10) # 10 is a minimal height and width
    fig.show()
    
    clear_output()
    time.sleep(0.5) # unless that, I had an issue with cutting logs after this

I hope this helps someone.

1 Like