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

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.

Hi @Acro17 please edit your post to use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)

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.

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