Skip to content

Instantly share code, notes, and snippets.

@jsignell
Last active March 20, 2019 19:41
Show Gist options
  • Save jsignell/86f80c916cd22619083395f5ae9c4220 to your computer and use it in GitHub Desktop.
Save jsignell/86f80c916cd22619083395f5ae9c4220 to your computer and use it in GitHub Desktop.
Multipane File Browser implemented in Panel
import os
import panel as pn
path = os.getcwd()
def get(event):
"""When dir selected populate next pane, remove any extra panes"""
got = event.new[0]
if os.path.isdir(got):
items = sorted(os.listdir(got))
options=dict(zip(items, (os.path.join(got, item) for item in items)))
next_pane = pn.widgets.MultiSelect(options=options, size=14)
next_pane.param.watch(get, 'value')
index = row.objects.index(event.obj)
if len(row.objects) > (index + 1):
row[index + 1] = next_pane
else:
row.append(next_pane)
last_index = index + 1
else:
last_index = row.objects.index(event.obj)
while len(row) > last_index + 1:
row.pop(last_index + 1)
items = sorted(os.listdir(path))
options = dict(zip(items, (os.path.join(path, item) for item in items)))
select = pn.widgets.MultiSelect(options=options, size=14)
select.param.watch(get, 'value')
row = pn.Row(select)
row.servable()
@jsignell
Copy link
Author

Each new dir opens in a new pane like:

Screen Shot 2019-03-20 at 3 39 54 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment