I’m working with a DataTable and I want to have some triggers that change the values in the table.
I’m able to change the source value without problem, however, I can’t get the displayed table to update when I do.
Here is a very simplified version of my code. When I click on the button, I expect the first value of col1 to change to ‘z’. When I check by sending the value to the log, it seems to have worked, however, the Table still show an ‘a’ there.
Can you help me find what I’m missing ?
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, Button
from bokeh.models.widgets import DataTable, TableColumn
from bokeh.layouts import column
import logging
import bokeh
import pandas as pd
df = pd.DataFrame({'col1': ['a', 'a', 'b', 'a', 'c', 'b', 'a'],
'col2': [1, 3, 3, 4, 2, 1, 3]
})
source = ColumnDataSource(df)
columns = [TableColumn(field = col, title=col) for col in df.columns]
data_table = DataTable(columns=columns,
source=source
)
but = Button(label = 'Change')
def change_value():
global source
source.data['col1'][0] = 'z'
logging.warning(source.data['col1'][0])
but.on_click(change_value)
lay = column(data_table, but)
curdoc().add_root(lay)



