☰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

Start the callback automatically

Community Support
JoeReis
JoeReis

I’m making an application that displays windy. However, windy updates only with f5. I would like him to update every 10 minutes.

I created the callback, and a button, and it’s working.

I want to delete the button and start the callback automatically, without the click of a button.

Follow my code.

from bokeh.driving import  count

from bokeh.models import ColumnDataSource, Div,TextInput, Paragraph, Button, CustomJS, ColumnDataSource

from bokeh.models.widgets import Panel, Tabs

from bokeh.models.tools import HoverTool

from bokeh.plotting import curdoc, figure, show

from bokeh.events import ButtonClick 

from bokeh.layouts import layout, row,column,gridplot

from bokeh.server.server import Server

from functools import partial


windyLat="5.550"

windyLong="-0.0200"

coordenadas = [windyLat,windyLong]

source = ColumnDataSource(data=dict(coordenadas=coordenadas))

windyMap='<iframe width="800" height="350" src="https://embed.windy.com/embed2.html?lat='+windyLat+'&lon='+windyLong+'&detailLat='+windyLat+'&detailLon='+windyLong+'&width=650&height=450&zoom=8&level=surface&overlay=wind&product=ecmwf&menu=&message=true&marker=true&calendar=now&pressure=&type=map&location=coordinates&detail=&metricWind=default&metricTemp=default&radarRange=-1" frameborder="0"></iframe>'

twindy= Div(text=windyMap,width=300, height=300,name="twindy",sizing_mode='stretch_both')

callback = CustomJS(args=dict(source=source),code="""

var data= source.data.coordenadas;

var windyLat=data[0];

var windyLong=data[1];

setInterval(function(){

    document.getElementsByTagName('iframe')[0].src='https://embed.windy.com/embed2.html?lat='+windyLat+'&lon='+windyLong+'&detailLat='+windyLat+'&detailLon='+windyLong+'&width=650&height=450&zoom=8&level=surface&overlay=wind&product=ecmwf&menu=&message=true&marker=true&calendar=now&pressure=&type=map&location=coordinates&detail=&metricWind=default&metricTemp=default&radarRange=-1'+'&no-cache='+Math.random()

    }, 1000)

 """)

callback

btn=Button(label="No Alerts",button_type="success",width=80)

btn.js_on_click(callback)
   
r=row(twindy,btn)

show(r)
⌁   Link to post
carolyn
carolyn

Hi @JoeReis,

There’s a DocumentReady event added to Bokeh Server in 2.2. The idea is that an action can be automatically triggered to happen as soon as the application’s initial load is complete.

This requires that you run a Bokeh Server, though, rather than a standalone script like you show here. For standalone scripts, there is no ready built-in solution.

⌁   Link to post

End of archived discussion · Replies are disabled