Getting filename and value from FileInput in the same time

Hi all!
I have a bokeh app using FileInput. However when i tried to get filename and value cannot getting the filename because of the problem i mentioned below.

Basic code:


def get_filename(attr, old, new):
    global fn
    print(new + " is selected")

def upload_file(attr, old, new):
    # some codes

file_input = FileInput(name="fileinput", accept=".csv")
file_input.on_change('filename', get_filename)
file_input.on_change('value', upload_file)

and it returns:

filename.csv is selected

It’s because upload_file function start first somehow. It shouldn’t be. Do you know guys the reason or any method to get filename and value from FileInput in the same time? I tried couple of things but everytime upload_file function is the first one to start, so i cannot getting the filename in that function.

A combined event is still an open issue:

For now you can simply have one callback for value that also accesses the filename (since it will be set by that point).

@Bryan yes i’m using that way for now but I don’t like it :slight_smile: thank you! I hope soon we could get that feature.

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