adding new models to a document

In the code below, the first time I click the button it takes ~1 sec to add the 10 tabs, the second time it takes ~5 sec to add the next 10 tabs, the third time it takes ~10-15 sec etc.

from bokeh.plotting import figure
from bokeh.models import Tabs,Panel,Button
from bokeh.io import curdoc

button = Button(label=‘add tabs’, width=200)

main = Tabs(tabs=)

j=0
def add_tabs():
global j
main.tabs+=[Panel(child=figure(),title=‘tab’+str(j+i)) for i in range(10)]
j+=10

button.on_click(add_tabs)

curdoc().add_root(button)
curdoc().add_root(main)

``

It seems to update all the tabs each time. Can I add a new Panel to a Tabs object without updating all the other Panels?

Hi,

I think you will have to wait for some upcoming changes to see other avenues for improvement. There are various deficiencies with tabs that are "overlookable" for small cases, but are probably not acceptable with 20+ tabs. Bokeh uses a constraint solver to solve for its layout positioning, and currently creates one set of constraints per document root, which means everything in all tabs add up to one enormous pile of layout constraints, even though only one tab is visible at a time.

The upcoming work will allow individual document roots to be individually "addressable" for templating purposes, so you will be able to use a other/better JS tab/panel libs than Bokeh's built in one, and put different plots (or whatever) in each tab. Bokeh will not try to combine layout constraints across them if they are different document roots. I am going to be working on this next week, I think it's probably one of the most important remaining pre-1.0 tasks.

If you are after simple and quick, Bokeh layouts are terrific, but if you needs something more sophisticated and polished, realistically we will never be able to make Bokeh layouts all that much better (we don't have the experience in team, and it would be duplicative of lots of other existing work) so a way to embed individual document roots in a template should provide a relief valve for that case.

Thanks,

Bryan

···

On Sep 29, 2017, at 09:16, Sébastien Roche <[email protected]> wrote:

In the code below, the first time I click the button it takes ~1 sec to add the 10 tabs, the second time it takes ~5 sec to add the next 10 tabs, the third time it takes ~10-15 sec etc.

from bokeh.plotting import figure
from bokeh.models import Tabs,Panel,Button
from bokeh.io import curdoc

button = Button(label='add tabs', width=200)

main = Tabs(tabs=)

j=0
def add_tabs():
global j
main.tabs+=[Panel(child=figure(),title='tab'+str(j+i)) for i in range(10)]
j+=10

button.on_click(add_tabs)

curdoc().add_root(button)
curdoc().add_root(main)

It seems to update all the tabs each time. Can I add a new Panel to a Tabs object without updating all the other Panels?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7af0c69e-cbf4-4b00-bde6-a84740b5e8b0%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan thanks for the answer,

I think I should just change the design of the app until the new tabs are out. I guess tabs + panels can be replaced by buttons pushing stuff from a source to a fixed layout, since all my panels content have the same layout.

···

Le samedi 30 septembre 2017 10:40:11 UTC-4, Bryan Van de ven a écrit :

Hi,

I think you will have to wait for some upcoming changes to see other avenues for improvement. There are various deficiencies with tabs that are “overlookable” for small cases, but are probably not acceptable with 20+ tabs. Bokeh uses a constraint solver to solve for its layout positioning, and currently creates one set of constraints per document root, which means everything in all tabs add up to one enormous pile of layout constraints, even though only one tab is visible at a time.

The upcoming work will allow individual document roots to be individually “addressable” for templating purposes, so you will be able to use a other/better JS tab/panel libs than Bokeh’s built in one, and put different plots (or whatever) in each tab. Bokeh will not try to combine layout constraints across them if they are different document roots. I am going to be working on this next week, I think it’s probably one of the most important remaining pre-1.0 tasks.

If you are after simple and quick, Bokeh layouts are terrific, but if you needs something more sophisticated and polished, realistically we will never be able to make Bokeh layouts all that much better (we don’t have the experience in team, and it would be duplicative of lots of other existing work) so a way to embed individual document roots in a template should provide a relief valve for that case.

Thanks,

Bryan

On Sep 29, 2017, at 09:16, Sébastien Roche [email protected] wrote:

In the code below, the first time I click the button it takes ~1 sec to add the 10 tabs, the second time it takes ~5 sec to add the next 10 tabs, the third time it takes ~10-15 sec etc.

from bokeh.plotting import figure

from bokeh.models import Tabs,Panel,Button

from bokeh.io import curdoc

button = Button(label=‘add tabs’, width=200)

main = Tabs(tabs=)

j=0

def add_tabs():

global j

main.tabs+=[Panel(child=figure(),title=‘tab’+str(j+i)) for i in range(10)]

j+=10

button.on_click(add_tabs)

curdoc().add_root(button)

curdoc().add_root(main)

It seems to update all the tabs each time. Can I add a new Panel to a Tabs object without updating all the other Panels?


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7af0c69e-cbf4-4b00-bde6-a84740b5e8b0%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.