holoviz / param

Param: Make your Python code clearer and more reliable by declaring Parameters
https://param.holoviz.org
BSD 3-Clause "New" or "Revised" License
412 stars 69 forks source link

Updating `path` on a `File/MultiFileSelector` Parameter updates `objects` #814

Closed maximlt closed 10 months ago

maximlt commented 11 months ago

Fixes https://github.com/holoviz/param/issues/545 Supersedes https://github.com/holoviz/param/pull/546

The issue stated about FileSelector:

FileSelector behaves like Selector and should as such set its value to the first item of objects, objects being the result of a glob on path.

This has been addressed in https://github.com/holoviz/param/pull/801.

About MultiFileSelector:

Also the docs currently state that the default value is all of the matched files, but in practice it's None.

While that's what the docs say, the behavior of ListSelector from which MultiFileSelector inherits is for default to be None so I'm not sure we should make this change without also updating ListSelector. Also, Panel maps the MultiFileSelector parameter to the FileSelector widget (the FileSelector Parameter being mapped to a simple Select or TextInput widget) and I don't think we'd want all the files to be selected by default.

import param

class P(param.Parameterized):
    ls = param.ListSelector(objects=[1, 2, 3])

a = A()

assert a.ls is None