☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Div not updating immediately

Community Support
Jack_Beanland
Jack_Beanland

Hi,

I have some data i/o that can take a while so I’m trying to implement a log and/or spinner to tell the user what is going on. However I’m finding that (when running from a button.onclick()) any updates I do to a div.text are only written after the whole callback function is finished.

I’ve included a minimal example where, on a button click, print to log, wait 3s, print to log. You can (should) see that the time strings are 3s apart (as they should be), but when you run it there is no change in the div for 3s then all output is written at once.

Is there something obvious I’m missing or something different I can do to get around this?

Using Bokeh 1.3.4 on Windows 10, anaconda Python 3.7.4

Thanks!
Jack

Example:
#test.py
import time
from datetime import datetime

from bokeh.models.widgets import Button, Div
from bokeh.io import curdoc
from bokeh.layouts import layout


def button_click():
    div.text = div.text + f"start waiting {datetime.now()}<br>"
    time.sleep(3)
    div.text = div.text + f"end waiting {datetime.now()}<br>"

div = Div(text="log<br>")

div_test_button = Button(label="Import Data")
div_test_button.on_click(button_click)

curdoc().add_root(layout(div_test_button, div))
⌁   Link to post

End of archived discussion · Replies are disabled