☰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

Use a callback of one widget in another widget or save the callback value

Community Support
Acro17
Acro17

Hello,

I am relatively new to Bokeh.
I want to e.g. use two FileInput to choose a data and a header csv data file.

When I finished configuring all my input data i want to press a button widget in order to plot sth.
The plot then needs the chosen data and the other information from the Widgets (e.g. a slider)

Am I using Bokeh in the wrong way when trying to achieve this? Is it only suitable for direct interaction on an already existing plot? And not to be understood as an UI?

Here is a snippet of my code:

def update_data(attrname, old, new):
    # Get the file names
    str_data = input_datafile.value
    str_header = input_headerfile.value
    # Get the current slider values
    float_eps = slider_epsilon.value
    float_shift_vs_sticky = slider_stickyvsshift.value
    return str_data, str_header


def start_calc(event):
    df_dataset, df_header, df_datatype = read_dataset(str_data, str_header)

for w in [slider_epsilon, slider_stickyvsshift, input_datafile, input_headerfile]:
    w.on_change('value', update_data)

button_start.on_event(ButtonClick, start_calc)

# Set up layouts and add to document
inputs = column(input_datafile, input_headerfile, slider_epsilon, slider_stickyvsshift, button_start)

I am searching for a way to connect the update_data event of the slider in a way that on button click i can use that value. From Qt e.g. i would expect sth like:

Click Button
buttonfct() input_datafile.get(text) or sth like that.

⌁   Link to post
baijingui
baijingui

Hi,Acro17

I make it work with global virable.
Define some global virable like slider_data, change it in the callback function of slider_data ,and use it in the callback function of button_click.

I don’t know if there is a more elegent method.

⌁   Link to post

End of archived discussion · Replies are disabled