How can I delete warning message W-1002(EMPTY_LAYOUT) [bokeh.core.validation.check]

Hi all,

I am making interactive plot with using Panel and Bokeh. But now I faced a problem. this problem is reporting warning message from jupyter notebook. My function works well as I wanted . But I want to delete this warning. Someone helps me.

alarm info

WARNING:bokeh.core.validation.check:W-1002 (EMPTY_LAYOUT): Layout has no children: Column(id=‘1231’, …)

Info [I tried]

When I delete ‘sidebar = tabs’ in my code, warning is not reported. But I need this sidebar.

My simple code is below

from bokeh.models import Panel, Tabs
import panel as pn
pn.extension()
from bokeh.plotting import figure

p1 = figure(width=300, height=300, name='Scatter')
p1.scatter([0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 2, 1, 0])

p2 = figure(width=300, height=300, name='Line')
p2.line([0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 2, 1, 0])

text1 = "# Slider 1"
text2 = "# Slider 2"

def tabs():
    return pn.Tabs(
        ('scatter', text1),
        ('line', text2)
    )

golden = pn.template.GoldenTemplate(title='Slider_Tabs_sample',sidebar=tabs )

golden.main.append(
    pn.Row(
        pn.Card(p1, title='Sample1'),   
        pn.Card(p2, title='Sample2'),   
    )
)

pn.config.sizing_mode = "scale_width"
pn.serve(golden)

output screen


sidebar works well. But I want to delate warning. Someone helps me.

Hi @kazux68k

I think this is due to a simple syntax error in your example.

The template expects layout items for the various areas, e.g. main, sidebar, etc.

You’ve passed a function to the sidebar argument when instantiating the template. Try the following replacement for that line; note the () to call the function and return the layout item.


golden = pn.template.GoldenTemplate(title='Slider_Tabs_sample',sidebar=tabs() )

Thank you for reply. I tried what you mentioned. Alarm doesn’t occur. It’s so good. But tab function doesn’t work. (Tab is disappeared (see attached screen shot) ). I want to have a tab function . What should I do ?

Screen shot

@kazux68k

Sorry for your troubles. I do not experience the same problem in my setup.

For completeness, the code I ran, which is just a modification to the aforementioned line in your original, is reproduced below.

I use the Anaconda distribution of python, and the environment I was running for your test case has the following relevant package versions.

python: 3.9.7
bokeh: 2.3.3
panel: 0.12.1

And here is a screen capture showing the tab – which is functional – appearing as expected.

Given that you’re seeing different behavior, see if it is an issue with different versions of the panel and/or bokeh packages you are using.

And, if you can narrow it down to a change in behavior among specific versions, it is probably worth posting the issue to the Holoviz panel discourse. This seems like a topic that more likely originates from panel’s template rather than bokeh models that are being wrapped in it.

The panel forum is here …

Holoviz panel discourse

CODE

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
"""

from bokeh.models import Panel, Tabs
import panel as pn
pn.extension()
from bokeh.plotting import figure

p1 = figure(width=300, height=300, name='Scatter')
p1.scatter([0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 2, 1, 0])

p2 = figure(width=300, height=300, name='Line')
p2.line([0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 2, 1, 0])

text1 = "# Slider 1"
text2 = "# Slider 2"

def tabs():
    return pn.Tabs(
        ('scatter', text1),
        ('line', text2)
    )

golden = pn.template.GoldenTemplate(title='Slider_Tabs_sample',sidebar=tabs() )

golden.main.append(
    pn.Row(
        pn.Card(p1, title='Sample1'),   
        pn.Card(p2, title='Sample2'),   
    )
)

pn.config.sizing_mode = "scale_width"
pn.serve(golden)
1 Like

Re-reading your original post, I see that you’re using a jupyter notebook, which I don’t use, so cannot comment on how that might come into play.

I ran the code as follows (assuming it is a python file named golden.py)


 % python golden.py
1 Like

Thank you for your quick reply. I appreciate you.
I use jupyter notebook and my version are listed as below. My version is older than yours. At first , I update my version and try again. I report it later, Thanks

Python 3.7.0
bokeh 2.3.2
panel 0.11.3

your version

Thank you for your kind. I update my panel from 0.11.3 to 0.12.1. My function works well and Alarm message is not reported . I’m so sorry for bothering you.

1 Like

Great that it is working. Certainly not a bother; the discourse forum exists to help others.

Cheers

2 Likes