I’m using the
FileInput model to upload a file.
After uploading a file, I click the “choose file” button again and click “cancel” in the file explorer dialog.
After doing so, the file name of the previous file I’ve uploaded disappears and instead I see “No file chosen”.
I tried to set a callback that is triggered on any change of the
filename property but this callback isn’t being invoked (I tried the same for the “value” property as well). It seems like the properties of the
FileInput instance stay the same yet the “No file chosen” message appears.
Here’s a MWE:
from bokeh.models.widgets.inputs import FileInput
from bokeh.io import curdoc
# File input.
file_input = FileInput()
# Run each time the "filename" property is changed.
def on_change(attr, old, new):
Is that a known bug?
@roinr I think perhaps the docs will need some clarification. (cc @timo) On the Bokeh side, the
value properties only update when there is actual data that was successfully uploaded. If the browser widget shows something like “No file chosen” when an upload is cancelled, that is internal to the widget and invisible to us. I.e. the behavior you describe is what I would expect—no upload means no property changes.
In retrospect, it’s possible it would have been better to emit a one-off “fire and forget” event when upload is successful, rather than setting property values, since that would avoid any confusion like this, but I doubt that’s something we would try to change at this point.
I opened Update docs for FileInput · Issue #11967 · bokeh/bokeh · GitHub to update the docs. @roinr feel free to add your thoughts to the discussion there or make a PR!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.