Testing bokeh 3.3.0 children.remove in layout I see different beavior behaviour

I’m testing the new version 3.3.0

It seems that the behavior that children.remove using layout is changed.

I’m attaching an example from which you can see that pressing the execute key is not able to redraw a datatable.
In previous versions of bokeh, everything worked.

Where am I wrong?

Kind regards

from datetime import date
from random import randint
from bokeh.plotting import curdoc
from bokeh.models import ColumnDataSource
from bokeh.layouts import Column
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn, Div
from bokeh.plotting import figure, output_file, show
from bokeh.models.widgets import Button
from bokeh.layouts import row, column,layout

from functools import partial
from random import randint

def updateColumnDataSource():
    data = dict(
        col_a=['a','b','d','e'],
        col_b=[randint(0, 100) for i in range(4)],
    )
    sourceCDS = ColumnDataSource(data)
    print(data)
    colonne = [
            TableColumn(field="col_a", title="Customer"), 
            TableColumn(field="col_b", title="Value")
        ]
    data_table = DataTable(source=sourceCDS, columns=colonne, width=400, height=1000)
    return data_table

def cancellaAllPlot():
    global curdoc

    print("deleteAllPlot")
    idRowLayout=curdoc().get_model_by_name("colonnaPlot")
    if idRowLayout!=None:
        children = idRowLayout.children
        idColumn=curdoc().get_model_by_name("colonnaPlot1")
        if idColumn!=None:
            children.remove(idColumn)
    return

def aggiungiPlot(listaPlot1):
    global curdoc
    print("addPlot")
    idRowLayout=curdoc().get_model_by_name("colonnaPlot")
    if idRowLayout!=None:    
        if len(listaPlot1)>0:   
            colonnaPlot1=column(listaPlot1,name="colonnaPlot1",width=100)
            idRowLayout.children.append(colonnaPlot1)
    return


def eseguiBottoneEsegui(bottone):    
    print("execute ButtonEsegui")
    cancellaAllPlot()
    dataTable=updateColumnDataSource()
    listaPlot1=[bottone,dataTable]
    aggiungiPlot(listaPlot1)
    bottone.button_type="success"
    bottone.label="Esegui"
    print("finish ButtonEsegui")
    return

def callbackBottoneEsegui(new,bottone):
    print("callbackBottoneEsegui")
    bottone.button_type="warning"
    bottone.label="just moment..."
    eseguiBottoneEsegui(bottone)
    return

def createButton(testo,nome,larghezza): 
    bot=Button(label=testo,button_type="success",name=nome,width=larghezza)
    return bot

data = dict(
    col_a=['a','b','d','e'],
    col_b=[randint(0, 100) for i in range(4)],
)
sourceCDS = ColumnDataSource(data)
colonne = [
        TableColumn(field="col_a", title="Customer"), 
        TableColumn(field="col_b", title="Value")
    ]
data_table = DataTable(source=sourceCDS, columns=colonne)
data_table.columns[0].width=150
data_table.columns[1].width=150

bottoneEsegui=createButton('Exec','buttonEsegui',100)
bottoneEsegui.on_click(
    partial (callbackBottoneEsegui,bottone=bottoneEsegui))

listaPlot1=[bottoneEsegui,data_table]
colonnaPlot1=column(listaPlot1,name="colonnaPlot1",width=400)
colonnaPlot=column(row(colonnaPlot1,name="colonnaPlot"),width=400)

mainLayout=layout(row(colonnaPlot))

curdoc().add_root(mainLayout)

I am using this library
bokeh 3.3.0
configparser 6.0.0
contourpy 1.1.1
cx-Oracle 8.3.0
et-xmlfile 1.1.0
greenlet 3.0.1
Jinja2 3.1.2
MarkupSafe 2.1.3
numpy 1.26.1
openpyxl 3.1.2
packaging 23.2
pandas 2.1.2
Pillow 10.1.0
pip 23.3.1
python-dateutil 2.8.2
pytz 2023.3.post1
PyYAML 6.0.1
setuptools 65.5.0
six 1.16.0
SQLAlchemy 2.0.22
tabulate 0.9.0
tornado 6.3.3
typing_extensions 4.8.0
tzdata 2023.3
xlwt 1.3.0
xyzservices 2023.10.1

Sorry
close this question.
All work very fine.
I have found and solved the problem.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.